Wednesday, 30 March 2016

how to fix org.java_websocket.exceptions.WebsocketNotConnectedException

if you see this error:

 at org.java_websocket.WebSocketImpl.send(
 at org.java_websocket.WebSocketImpl.send(
 at org.java_websocket.client.WebSocketClient.send(
 at com.github.nkzawa.engineio.client.transports.WebSocket$
 at com.github.nkzawa.engineio.parser.Parser.encodePacket(
 at com.github.nkzawa.engineio.parser.Parser.encodePacket(
 at com.github.nkzawa.engineio.client.transports.WebSocket.write(
 at com.github.nkzawa.engineio.client.Transport$
 at com.github.nkzawa.thread.EventThread.exec(
 at com.github.nkzawa.engineio.client.Transport.send(
 at com.github.nkzawa.engineio.client.Socket$7$1$
 at com.github.nkzawa.engineio.client.transports.Polling$1$
 at com.github.nkzawa.engineio.client.transports.Polling$1$
 at com.github.nkzawa.emitter.Emitter$
 at com.github.nkzawa.emitter.Emitter.emit(
 at com.github.nkzawa.engineio.client.transports.Polling._onData(
 at com.github.nkzawa.engineio.client.transports.Polling.onData(
 at com.github.nkzawa.engineio.client.transports.PollingXHR$5$
 at com.github.nkzawa.thread.EventThread$
 at java.util.concurrent.ThreadPoolExecutor.runWorker(
 at java.util.concurrent.ThreadPoolExecutor$

You will have no idea why your app crashed, and this error trace gives no clue.

Actually it is Socketio error, you can fix it by setting okhttp as the client:


I used to use:

compile ''

To fix this I did this:

compile ('') {
    // excluding org.json which is provided by Android    exclude group: 'org.json', module: 'json'}


This lib's source code is used to under nkzawa's personal project, and packages are com.github.nkzawa.*.

nkzawa is still the author of the latest code, but he has moved it to's repo and package nams were changed, so if you used to use 0.3.0, after you changed to 0.7.0 you should change package name in your code, you don't need to change your code. (just change import, your IDE will tell you)

No comments:

Post a comment