Use ...

SuspendToken org.eclipse.jetty.websocket.api.Session#suspend()

http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/websocket/api/Session.html#suspend--

That will suspend the read events until you call the SuspendToken#resume()

Be aware that if the client sends PING frames, the client (and any
intermediary) can terminate the connection early for lack of response to
the PING.

It might sense to just close the client connection for spamming instead.

Invent a close code in the 4000-4999 range and just close the offending
connection.


Joakim Erdfelt / joa...@webtide.com

On Tue, Oct 18, 2016 at 10:21 AM, Alexander Farber <
alexander.far...@gmail.com> wrote:

> Hello Dmitry -
>
> On Tue, Oct 18, 2016 at 6:55 PM, Dmitry Polovka <messa...@messaged.lv>
> wrote:
>
>> Hey, is there any way to reject WebSocket writes from client side? I want
>> clients only to listen and not waste jetty resources if someone would spam
>> the connection with messages. So basically one direction messaging, server
>> to client.
>>
>
> have you tried setting policy to accept 1 byte only (I think 0 didn't work
> for me)?
>
>  public class MyServlet extends WebSocketServlet {
>     @Override
>     public void configure(WebSocketServletFactory factory) {
>         factory.getPolicy().setMaxBinaryMessageSize(1);
>         factory.getPolicy().setMaxTextMessageSize(1);
>         factory.register(MyListener.class);
>     }
> }
>
> Greetings from Germany
> Alex
>
> _______________________________________________
> jetty-users mailing list
> jetty-users@eclipse.org
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
jetty-users@eclipse.org
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to