Skip to content
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

Failure in SSL library or Connection Hangs #719

Open
TestTito opened this issue Jun 7, 2018 · 5 comments
Open

Failure in SSL library or Connection Hangs #719

TestTito opened this issue Jun 7, 2018 · 5 comments

Comments

@TestTito
Copy link

TestTito commented Jun 7, 2018

Expected Behavior

Trying to connect to the secure websocketserver (wss) the first time i start the app it always work.
Then after a few connection/reconnections, it becomes unstable.
When I try to connect it just hangs and nothing shows up on server side or SSl error described below.
The server and web application works perfectly if i start everything without https/wss

Current Behavior

The Wss connection hangs and is not reachable after a few attemps 2-3
I stress test too with simple websocket client extension in chrome
and it does the same, sometimes it just hangs, and then the wss is not reachable for a few seconds.

Possible Solution

no idea I tryed to debug in unwrap() and read() of SSLSocketchannel function but i can't seem to find a problem there

Steps to Reproduce (for bugs)

1.open chrome on my webpage or client websocket chrome extension
2.open/close a connection multiple times
3.it will hang after 2-3 connection attempts
4.

Debug log (for bugs)

06-06 14:55:13.638 18568-18711/com.regulvar.remotecontroller I/System.out: Removing connection which is not in the connections collection! Possible no handshake recieved! org.java_websocket.WebSocketImpl@ea78735
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: javax.net.ssl.SSLException: javax.net.ssl.SSLProtocolException: Read error: ssl=0xdc81ba80: Failure in SSL library, usually a protocol error
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: error:100bd10c:SSL routines:ssl3_get_record:WRONG_VERSION_NUMBER (external/boringssl/src/ssl/s3_pkt.c:305 0xed92976f:0x00000000)
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: at com.android.org.conscrypt.OpenSSLEngineImpl.unwrap(OpenSSLEngineImpl.java:497)
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:1014)
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: at org.java_websocket.SSLSocketChannel.read(SSLSocketChannel.java:158)
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: at org.java_websocket.SocketChannelIOHelper.read(SocketChannelIOHelper.java:38)
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: at org.java_websocket.server.WebSocketServer.run(WebSocketServer.java:406)
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: at java.lang.Thread.run(Thread.java:818)
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: Caused by: javax.net.ssl.SSLProtocolException: Read error: ssl=0xdc81ba80: Failure in SSL library, usually a protocol error
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: error:100bd10c:SSL routines:ssl3_get_record:WRONG_VERSION_NUMBER (external/boringssl/src/ssl/s3_pkt.c:305 0xed92976f:0x00000000)
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_read_BIO(Native Method)
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: at com.android.org.conscrypt.OpenSSLEngineImpl.unwrap(OpenSSLEngineImpl.java:477)
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller W/System.err: ... 5 more
06-06 14:55:16.188 18568-18711/com.regulvar.remotecontroller I/System.out: Removing connection which is not in the connections collection! Possible no handshake recieved! org.java_websocket.WebSocketImpl@7726d3b

Context

Trying to connect from a Web Page and establish a simple wss connection to exchange some datas and commands.

Your Environment

  • Java version: Android marhsmallow on a Samsung Galaxy Tab A 10.1 (server side)
  • Operating System and version: windows 10 on chrome (Version 67.0.3396.62 )(client side)

I created my Certificate with this line:
keytool -genkey -validity 3650 -keystore "keystore.jks" -storepass "password"
// -keypass "password" -alias "company" -keyalg RSA –keysize 2048 -dname "CN=domain,
// OU=RD, O=company, L=town, S=province, C=country"
and then I convert the jks to bks with the portecle application

Well I hope i gave enough information let me know if you guys need something else.

Thank you

David

@marci4
Copy link
Collaborator

marci4 commented Jun 8, 2018

Hello @TestTito,

thank you very much for your bug report.

Do you think this issue is caused by https://github.com/TooTallNate/Java-WebSocket/wiki/FAQ:-Secure-WebSockets#handshake-error-on-android?

SSl on Android is sometimes very buggy, so it could be related to this.
Apart from this, I know that our current method is not bug free, so it could be related to this as well (See #717).

Best regards,
marci4

@TestTito
Copy link
Author

TestTito commented Jun 8, 2018

Yeah I did the customSSL the only protocols left are TLSV1.2 TLSV1.1 and TLSV1
I did remove some cyphers too, and I tryed every cyphers one by one to see if it could help.

So I don't know why it keeps having some SSL exceptions when i am suppose to use TLS?

I tryed to use SSLSocketChannel and SSLSocketChannel2 both outputs the same error.

I am out of ideas :( thanks for your reply.

@TestTito
Copy link
Author

@marci4 Hi, I have tested AndroidAsync from Koush just to know if it wss works well. It is WAY more stable on the WSS then this one I am wondering if we could compare the ssl implementation inside Koush one to find the clue of the exceptions?

@marci4
Copy link
Collaborator

marci4 commented Jun 18, 2018

Hello @TestTito,

since I am very busy in RL, I do not have the time for this!
Most of my free time is already gone managing open issues and stuff...
Anyway, feel free to do contribute and compare yourself!

Best regards,
marci4

@tigrehuang
Copy link

Please try a different version of JRE. This is how I did when I found this issue. And please let me know if it doesn't work for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants