Open downtownallday opened 11 years ago
I experienced the same issue and this fix worked for me. One additional note, at least on Android, if the socket disconnects with a connectivity change, be sure to use the SocketIO.reconnect call rather than disconnecting and creating a new connection. There is an issue where the backgroundTask Timer object is leaked that I have yet to solve.
I think even I am facing this issue. Is there anyway through which I can verify if this solves the issue or not? Basically How can list all those threads?
I did have some leaking Threads problem too, and the above fix didn't change anything for me. Updating the websocket.jar to the newest version from https://github.com/TooTallNate/Java-WebSocket did the trick for me. I had to implement one more abstract method in WebSocketTransport then.
@veeru-as on DDMS select your process, then click Start Method Profiling (looks like a cascade arrow whith a red circle), wait a one or two seconds and press again. That will open a new view showing one row for each thread. There are other ways but I like this more because you can see wich thread is consuming the cpu across time
It helped me a great deal !!!!
Thanks a lot :)
what is the status on this? i can confirm this behaviour (j2se, not on android).
I have been experimenting with this library for a couple of months, and it seems to work well. Thanks to those who contributed. I wanted to share a fix to a problem where the JVM will not shut down properly because of lingering non-daemon threads.
After you connect to a SSL server using the websocket transport, you will see a thread named "pool-1-thread-1" appear. If you reconnect, or connect to a different server you'll see an additional "pool-2-thread-1" and so on.
These threads don't die and are non-daemon. I have tracked the problem down to the constructor call in org.java_websocket.client.DefaultSSLWebSocketClientFactory(SLContext sslContext), which calls "Executors.newSingleThreadScheduledExecutor()". The thread created by this function is not reused and never shut down.
Here's the fix I made to WebsocketTransport.java: