You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I found something. My app is crashing (waits for 20sec before error popup) if I try to close the connection when it's not opened. So let say I execute
socket.start();
socket.close();
in that case the app will hang and Fore/Wait error will pop up.
So... I'm closing the connection when finishing the activity. User can see the activity for just a sec before it presses the back button and close/abort the connection. If the activity is closed immediately this error pops up if I wait for a few seconds and close the connection everything is working.
Can you tell me what to do in tat case? Do you know how to fix that?
Hmmm, I'm not sure I completely understand what it is you are experiencing. Do you have a stack trace or anything to go from? At a guess I'd say that there must be some field that is not initialized until open and you are getting an NPE, but nothing is jumping out at me in the source. I can say that I am not using it the way you are, so it is possible we are triggering different behavior.
One thing I do see immediately: In the Android implementation, you should not manually call start (sorry - not documented well except in WebSocket.java). Before the constructor returns, it posts a message to the handler that will call start() on the next tick (presumably after you've set everything up).
Given that you are calling it manually, I think the sequence that is actually executing is:
new AndroidWebSocket()
socket.start()
socket.close()
-- Message Processing --
socket.start()
This isn't correct, but it should also be guarding itself from double calls, so I'm not seeing immediately where the error could be coming from. A stack trace should help pinpoint it.
Activity
stellaraccident commentedon Jul 7, 2011
Hmmm, I'm not sure I completely understand what it is you are experiencing. Do you have a stack trace or anything to go from? At a guess I'd say that there must be some field that is not initialized until open and you are getting an NPE, but nothing is jumping out at me in the source. I can say that I am not using it the way you are, so it is possible we are triggering different behavior.
One thing I do see immediately: In the Android implementation, you should not manually call start (sorry - not documented well except in WebSocket.java). Before the constructor returns, it posts a message to the handler that will call start() on the next tick (presumably after you've set everything up).
Given that you are calling it manually, I think the sequence that is actually executing is:
This isn't correct, but it should also be guarding itself from double calls, so I'm not seeing immediately where the error could be coming from. A stack trace should help pinpoint it.
xpepermint commentedon Jul 7, 2011
Hey... no. 4... hum... can't do this to a user :). Sometimes you just want to close and forget.
stellaraccident commentedon Jul 7, 2011
You should be able to close and forget. If you've got any further details on the error I can try to track it down...