Android SDK WebsocketNotConnectedException

We have integrated and published an Android app with WCS Android SDK. We get the following exception in our crashlytics logs. Not able to understand what part of our code is throwing this exception and why

org.java_websocket.exceptions.WebsocketNotConnectedException
at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:573)
at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:550)
at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:145)
at com.flashphoner.fpwcsapi.ws.WebSocketChannelClient$2.run(WebSocketChannelClient.java:116)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:224)
at com.flashphoner.fpwcsapi.util.LooperExecutor.run(LooperExecutor.java:44)
 

Max

Administrator
Staff member
Good day.
org.java_websocket.exceptions.WebsocketNotConnectedException
This means application cannot establish websocket connection to WCS. Please check if WCS server you're trying to connect to is up and running, and Websocket ports 8080 and 8443 is not blocked.
 
This error is very intermittent and doesn't happen to everyone. The app crashes after this error. Is there any way to catch this error and show appropriate message instead of app crashing.
 

Max

Administrator
Staff member
Is there any way to catch this error and show appropriate message instead of app crashing.
You can wrap websocket session establishing to try-catch, for example
Java:
try {
    session = Flashphoner.createSession(sessionOptions);
} catch (WebsocketNotConnectedException e) {
    mPublishStatus.setText("Websocket connection failed")
}
 
Last edited:
Top