-
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
Clean up connections after connection closed #504
Comments
Hello @vikulin, first of all thank you for your input. Actually most of the time the connection is actually cleaned up by the IOException (remote closed connection). This is for sure cleaning up the connection! Apart from this conn.close() should also close the connection and clean everything up! (Tested it with replacing conn.sendPing() with conn.close( CloseFrame.ABNORMAL_CLOSE ); and cleaned it up as well) Do you have any situation when the connection is not cleaned up? Greetings |
Yes, I have. My app throws every time: Closing connection due to no pong received: org.java_websocket.WebSocketImpl Closing connection due to no pong received: org.java_websocket.WebSocketImpl@22cc90ed |
Hello @vikulin, Well that should not happen oO. I suppose you use Android. With which versions do you have this problem? Greetings |
No, I'm using your lib in desktop app under windows deployed into Apache tomcat servlet container. JDK 1.8, Windows 10 x86_64, I save your connection into a Map for a further broadcast in Ethereum messenger. This is a server side part of the messenger. Here is a client side where I receive these messages: |
Can you please point out where exactly you clean up connections Collection? |
Hello @vikulin, tested it with java 1.8.0_131 and its working... The connection is getting cleaned up in the WebSocketServer Do you have a simple test application where I can reproduce it for sure? Theoretically we could just use Greetings |
Yes, I have. Will build it soon
15 июня 2017 г. 21:33 пользователь "Marcel Prestel" <
notifications@github.com> написал:
… Hello @vikulin <https://github.com/vikulin>,
tested it with java 1.8.0_131 and its working...
The connection is getting cleaned up in the WebSocketServer
onWebsocketClose() which is called by closeConnection().
Do you have a simple test application where I can reproduce it for sure?
Theoretically we could just use closeConnection() instead of close().
Greetings
marci4
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#504 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAtYxifRD4gbLl7xxPuJiiSKi00tNDMgks5sEWoggaJpZM4N7End>
.
|
No need to run app. Let see on close sequence:
Actually flushAndClose method does not contain Collections clean up as you mentioned. |
Well for me it is still very interesting why the selector is not waking up and we get no IOException in the runnable... |
You should never relay on an Exception. It is slow approach catching by
try-catch block and should be closed connection by timeout.
16 июня 2017 г. 9:27 пользователь "Marcel Prestel" <notifications@github.com>
написал:
Well for me it is still very interesting why the selector is not waking up
and we get no IOException in the runnable...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#504 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAtYxmDWTH_EXnF76NALHoZUbJKNWDFuks5sEiBMgaJpZM4N7End>
.
|
Well there are things which are out of my power e.g. when I have to rely on the IOException telling me that the remote endpoint was closed. Nethertheless I would really like to understand why this is working in my development enviroment but not in yours! That is why I am asking for your code. |
I could send you my whole server side If had no security sensitive info
such as certificates. So I need to remove these files and modify my
project. Second things: how to reproduce the scenario. I connect to server
side with extended handshake. So only authorized users are allowed to make
connections with server side.
Could it be better if you debug the issue on my side remotely through
TeamViewer?
2017-06-16 9:41 GMT+03:00 Marcel Prestel <notifications@github.com>:
… Well there are things which are out of my power e.g. when I have to rely
on the IOException telling me that the remote endpoint was closed.
Nethertheless I would really like to understand why this is working in my
development enviroment but not in yours! That is why I am asking for your
code.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#504 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAtYxohPjFF_0NAloK7g1MAEl2lz4wrCks5sEiO2gaJpZM4N7End>
.
|
Accordingly to this article http://www.javaworld.com/article/2076498/core-java/simple-handling-of-network-timeouts.html Java throws IOException when destination address is unavailable and network returns appropriate response. But this case does not cover scenario when remote host does not respond. Are you handling both cases? I will try t fix it by my self adding InterruptedIOException try-catch block. Can you please send me a code line where to put it? |
Well then the source code is not an option ;) Let's try this a different way! To your question about InterruptedIOException: it extends from IOException so this is fine! The easiest workaround right now is change the code you posted earlier |
Handshake: } } Java:
Client side: Android 6.0 using the same lib: Java-WebSocket v1.3.4 |
Hello @vikulin, I was still not able to reproduce your issue in my development enviroment! Nethertheless I build you a new version of the jar in which I switched out the conn.close call with conn.closeConnection. https://www.dropbox.com/s/g46yhov8igq77es/java_websocket-1.3.5-SNAPSHOT.jar?dl=0 Greetings |
The issue was fixed by your change. App showed it once and no other such messages in log: Closing connection due to no pong received: org.java_websocket.WebSocketImpl@43305ffd Thanks a lot! |
Found only once: Do you synchronize HashMap? |
Never do a hotfix I quess! Well here is the fixed version which should not cause CurrentModificationException as well as deadlocks. https://www.dropbox.com/s/g46yhov8igq77es/java_websocket-1.3.5-SNAPSHOT.jar?dl=0 Sorry again :( Greetings |
Bugfix merged. Closing issue! Greetings |
I do believe this method should also clean up connections since its closed. I see only
conn.close( CloseFrame.ABNORMAL_CLOSE );
and nothing about cleaning up.
The text was updated successfully, but these errors were encountered: