-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If you close a websocket client before it has connected, the socket remains open #347
Comments
Hello @oakkitten, I used autobahn testsuite and with the current codebase the implementation passes any close test. Have you tried the latest version of the lib? Greetings |
No update for 2 months! Closing issue. |
just writing to confirm that this has been resolved. thanks for the awesome work, you rock! |
Thank you for your feedback @oakkitten. Happy to hear that this is solved! |
i'm seeing this problem again, on 1.3.7 and 1.3.9. here's how i connect
here's how i disconnect
log output
if i call
the sockets remain open as well i see that my server receives 7 bytes when |
Hello @oakkitten, why do you interrupt the connector? Could you open a separate issue with an example code so I can take a look at this? Thank you! |
actually my immediate problem was some code that must've been added by mistake in the development process. since the library doesn't accept socket factories, i was calling as to why i'm calling interrupted in the first place, well. it's just there to make sure the connections are closed immediately. on my device, i see that it takes up to 3 minutes to for
|
while i was poking around emulating slow connections, i also managed to get this:
|
Hello @oakkitten, socket factories will be added for WebSocketClient in 1.4.0 (See #770). Can you reproduce the slow connection close please for me? Looking at the null pointer, this should not happen, so I would be happy if you can provide an example application for this as well! Best regards, |
yeah i'm waiting for 1.4.0 to be released since i only do java on android, it might be a while before i can make some minimal demo. but it's still easy to replicate the issue if you simulate slow connection and server disappearance. i used i caught the NullPointerException in the same way, but it happened only once; didn't try reproducing it, might be very rare |
Hello @oakkitten, as you may see in my activity lately I am currently really busy with my normal job and real life in general. Therefore I simple do not have the time to reproduce such issues on my own and simply depend on others to provide a simple reproduction example. On the other hand you can simple fix it and open a PR for the issues you found. Best regards, |
ok bear with me here. by now i'm not really sure how the disconnection works at all. let's ignore now, this method ultimately calls but what if (btw, i'm not sure but can't these calls block as well?) |
i made a test here, it's very simple and should demonstrate what i'm talking about |
Hello @oakkitten, thank you very very much for this test! I will take a look at this and will get back to you. Best regards, |
Hello @oakkitten, with the help of your unit test I created a patch. What do you think of the changes? Best regards, |
if i read this right, you are interrupting but let's talk about but let's look at these are just the things i can spot on the very surface. the test is only so much useful; one probably should test this all with some random delays, maybe using some special real life mimicking environment? there's just so much spaghetti in the code, i don't know if there is a way to fix it in a sane way. with many potential threads calling all the methods and very little synchronization, it's just so hard to reason about what can potentially happen |
Maybe someone just needs to take his time and rewrite everything from the ground of. |
Maybe https://github.com/marci4/Java-WebSocket-Dev/tree/readystate is a start |
Hello, |
Hello @latinosamuel, no this issue awaits your pull request! Best regards, |
Hello @marci4 , Thank You. |
If the mistake bothers you, please fix it. |
based on oakkitten/Java-WebSocket/commit/b352aad06272b8
if i use a workaround technique of #346, i can get the
onClose
call. but if i attempt to close connection before it's been established (i.e. beforeonOpen
) call, the socket remains open long afteronClose
it might be related to the fact that Threads with SocketChannels, when used with SSL, do not get
interrupt()
ed. in my app, i have to close the socket to interrupt such a thread.The text was updated successfully, but these errors were encountered: