Fatal Exception: WebsocketNotConnectedException
Fatal Exception: WebsocketNotConnectedException
I implemented web3j for andrpoid library in my app(v.4.8.8-android). Sometimes my app crash with next stacktrace:
Fatal Exception: org.java_websocket.exceptions.WebsocketNotConnectedException at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:608) at org.java_websocket.WebSocketImpl.sendFrame(WebSocketImpl.java:634) at org.java_websocket.WebSocketImpl.sendPing(WebSocketImpl.java:641) at org.java_websocket.AbstractWebSocket$1.run(AbstractWebSocket.java:153) at java.util.TimerThread.mainLoop(Timer.java:562) at java.util.TimerThread.run(Timer.java:512)
Just web3j in my project used java_websocket. How to fix it issue?
Any version of Android
You likely have to connect to your websocket before using it in the constructor.
static {
WebSocketService ws = new WebSocketService("wss://....", false);
try {
ws.connect();
} catch (ConnectException e) {
e.printStackTrace();
}
web3j = Web3j.build(ws);
}
I can confirm, it can happen time to time after connection is established for 10-30mins not only on Android
@milory13 there were a series of updates on on websockets. Please could you confirm if this happens also on current web3j-4.9.7?
@gtebrean unfortunately today I use only local functional web3j, without connections to server
After several tests in my case is working so I\m closing this ticket. Feel free to reopen it if you spot it again on latest version.