Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Determining when WebSocketSession#getRemote is allowed

Woops - forgot to provide version. This is on Jetty-9.2.10



On Fri, May 15, 2015 at 5:44 PM, William Ferguson <william.ferguson@xxxxxxxxxxxxx> wrote:
First, thanks so much for such a fantastic product.
Jetty has been my go to web server for a *really* long time now and it never disappoints.

I have recently created a web app that uses WebSockets as the primary communication with its clients and it all works well. But we occasionally get the following WebSocketException

org.eclipse.jetty.websocket.api.WebSocketException: RemoteEndpoint unavailable, current state [CLOSING], expecting [OPEN or CONNECTED]
at org.eclipse.jetty.websocket.common.WebSocketSession.getRemote(WebSocketSession.java:252)
at au.com.xandar.obfuscated.cm.a(SourceFile:41)

when we are in the middle of processing an incoming request and attempt to get the remote endpoint in order to send a message back.

We have tried to mitigate by checking Session#isOpen but it uses a different condition to determine whether the Session is open than what #getRemote does, and it would also suffer from a potential race condition.

Other than catching the unchecked WebSocketException on #getRemote (which seems wrong) is there a definitive way to determine whether I can send to the client?
Wouldn't it perhaps be better if #getRemote returned null if the remote end point was no longer available?


William



Back to the top