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
Hello, our team using this library for connecting websocket server on Android platform,
sometimes, there are 'bad rsv 4' errors occurred. Seems same problem with #430.
The debug log above shows the WebSocketImpl treat the handshake response as normal websocket frame and decode it, then throw an InvalidFrameException.
Our client tries to reconnect to server endlessly when it is in condition of unstable network environment.
So is it possible that method org.java_websocket.WebSocketImpl#decode was invoked after WebSocketClient closed in some extreme cases?
Our client runs as an android system service, it invoke the async method connect() and close(), I think it's the reason of this issue, because the stupid client would invoke close() after connect() was invoked immediately and over and over again in some cases :(
I'm still trying to reproduce this issue, wait for my good news ;D
After thinking it carefully, you are right.
It still could happen even if check the ready state, readyState could changed from NOT_YET_CONNECTED to CLOSED or CLOSING after the state's check.
The effect of variable readyState is limited.
Maybe we should find another way to fix it, how about blocking the close() method until handshake
was completed?
How to solve this?
org.java_websocket.exceptions.InvalidFrameException: bad rsv 4
at org.java_websocket.drafts.Draft_10.translateSingleFrame(Draft_10.java:309)
at org.java_websocket.drafts.Draft_10.translateFrame(Draft_10.java:286)
at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:312)
at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:157)
at org.java_websocket.client.WebSocketClient.interruptableRun(WebSocketClient.java:230)
at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:188)
at java.lang.Thread.run(Thread.java:748)
Activity
marci4 commentedon Apr 27, 2017
Hello @zhoulifu
what do you mean with bad?
Greetings
marci4
zhoulifu commentedon Apr 27, 2017
@marci4 Sorry i just double click the Enter by mistake :(
marci4 commentedon Apr 27, 2017
Hello @zhoulifu,
no problem. Just was thinking wtf :D
Are you using the latest version 1.3.3?
If so, could you please provide an example application for me,, because right now I cannot reproduce this issue on my test enviroment.
Greetings
marci4
[-]'Bad'[/-][+]Bad rsv 4 on android[/+]zhoulifu commentedon Apr 27, 2017
Yes we are using java-websocket-1.3.3.
I'm afraid I can't provide the apk :D, furthermore, it doesn't hannped 100% in our test env :(
But, i'll try may best to produce this issue manually
marci4 commentedon Apr 27, 2017
Hello @zhoulifu
could you please activate the debug printouts with
WebSocketImpl.DEBUG = true;Could you tell me something about the client you use to connect to the server?
Greetings
marci4
zhoulifu commentedon Apr 27, 2017
Yes, WebSocketImpl.DEBUG is enabled, and I added some statements in source code
here was what I got
It seems that my conjecture was confirmed.
Our client runs as an android system service, it invoke the async method connect() and close(), I think it's the reason of this issue, because the stupid client would invoke close() after connect() was invoked immediately and over and over again in some cases :(
I'm still trying to reproduce this issue, wait for my good news ;D
marci4 commentedon Apr 27, 2017
Hello @zhoulifu,
so as I understand you correctly you use the client provided by this lib.
Could you then try if connectBlocking() and closeBlocking() "fixes" the issue?
Just a heads up, I am going on a little trip for a few days later today. Won't be able to reply then.
Greetings
marci4
zhoulifu commentedon Apr 27, 2017
It seems those blocking methods are helpful, it works fine so far.
Thanks for your advice, and have a nice trip! :)
zhoulifu commentedon Apr 27, 2017
Hello @marci4 , please checkout this, it could produce this problem on my computer.
ENV:
Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
Ubuntu 14.04.5 LTS
Linux 4.4.0-75-generic
Java 1.8.0_101 HotSpot(TM) 64-Bit (build 25.101-b13)
Thanks :)
Fix TooTallNate#465
Fix TooTallNate#465
zhoulifu commentedon Apr 28, 2017
Hi @marci4, I think it would be helpful, PTAL
marci4 commentedon May 2, 2017
Hello @zhoulifu,
thx for looking into this issue a bit more :)
This issue sometimes happens with your example, but it looks like your patch fixes it.
Going to test against side affects now ;)
Greetings
marci4
marci4 commentedon May 2, 2017
It is me again.
Soo all the test cases pass.
Looks like it isn't just an android problem, but it is more likely to occur since phones have slower cpus.
Could you please open a pull request for your fix?
Greetings
marci4
zhoulifu commentedon May 2, 2017
After thinking it carefully, you are right.
It still could happen even if check the ready state, readyState could changed from NOT_YET_CONNECTED to CLOSED or CLOSING after the state's check.
The effect of variable readyState is limited.
Maybe we should find another way to fix it, how about blocking the close() method until handshake
was completed?
marci4 commentedon May 2, 2017
Well it still would not solve different clients, and I think it is an unexpected behavior that a non blocking method may block.
Gonna check when readyState can change and if we just include an additional check for this case.
Greetings
marci4
zhoulifu commentedon May 2, 2017
If so, I think this would be better
WDYT?
marci4 commentedon May 2, 2017
Yes I like it this way more.
Readystate is changed to open just during handshake so it should not be a problem.
Greetings
marci4
Fix TooTallNate#465
Merge pull request #470 from zhoulifu/issue465
Eucalyptus-fructicetorum commentedon Sep 5, 2022
How to solve this?
org.java_websocket.exceptions.InvalidFrameException: bad rsv 4
at org.java_websocket.drafts.Draft_10.translateSingleFrame(Draft_10.java:309)
at org.java_websocket.drafts.Draft_10.translateFrame(Draft_10.java:286)
at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:312)
at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:157)
at org.java_websocket.client.WebSocketClient.interruptableRun(WebSocketClient.java:230)
at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:188)
at java.lang.Thread.run(Thread.java:748)