NaikSoftware / StompProtocolAndroid

STOMP protocol via WebSocket for Android
MIT License
591 stars 265 forks source link

IllegalStateException with unreachable host #33

Open Erhannis opened 7 years ago

Erhannis commented 7 years ago

If you (without waiting) try to connect to an unreachable host, send a message, disconnect, and connect again, the final connect attempt crashes:

W/System.err: java.lang.IllegalStateException: Already have connection to web socket W/System.err: at ua.naiksoftware.stomp.WebSocketsConnectionProvider.createWebSocketConnection(WebSocketsConnectionProvider.java:72) W/System.err: at ua.naiksoftware.stomp.WebSocketsConnectionProvider.messages(WebSocketsConnectionProvider.java:66) W/System.err: at ua.naiksoftware.stomp.client.StompClient.connect(StompClient.java:89) W/System.err: at ua.naiksoftware.stomp.client.StompClient.connect(StompClient.java:61) W/System.err: at ua.naiksoftware.stomp.client.StompClient.connect(StompClient.java:48) W/System.err: at com.aptima.csms.gpssensor.MainActivity.onStart(MainActivity.java:73) W/System.err: at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1260) W/System.err: at android.app.Activity.performStart(Activity.java:6287) W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405) W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2506) W/System.err: at android.app.ActivityThread.-wrap11(ActivityThread.java) W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363) W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102) W/System.err: at android.os.Looper.loop(Looper.java:148) W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5491) W/System.err: at java.lang.reflect.Method.invoke(Native Method) W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

(If, after disconnect(), you wait until "java.net.ConnectException: failed to connect to /192.168.1.134 (port 61613): connect failed: EHOSTUNREACH (No route to host)" happens, then the subsequent connect() doesn't crash.)

forresthopkinsa commented 7 years ago

This problem was probably fixed with the 1.4.1 update, back in August. It repaired several race conditions. If you're still able to reproduce this issue, please update it.

manfcas commented 6 years ago

Issue still present on version 1.4.4, same stack trace.