Skip to content

Instability on WSS Connections, only works when one client abandon connection #466

Closed

Description

@Irahe

hello, im implementing a simple secure websocket server and client. My server implementation is the same as provided in the example folders, and im using websocket.org to test this implementation (http://www.websocket.org/echo.html). I can connect using WSS. However, to do so, i need to request connection on thwo tabs, and close one of them. The other then, connects perfectly. If i dont close one of the tabs, all connections timeout. The server does not give me any exceptions on console not when it connects nor when it cant.
I dont have many experience with WSS. However, WS implementaton works out of the box with this same server.
For my experience, seems like a endless loop is created when i try to connect. And only breaks when i kill one of the tabs trying to connect.

For the record, im using version 1.3.3

Can you help me out pls?! =*

EDIT -

Hello again, im posting a sample project to illustrate my problem. With this project is my keystore.jks.
The password for the keystore is password and the password for the key is password, as shown on my source.

Please, help out.
d3_Servidor.zip

Activity

  1. marci4 commented on May 2, 2017

    @marci4
    Collaborator

    Hello @Irahe,

    I just tested your problem with my wss which I use in production and the issue mentioned does not occur for me.

    Going to look into your sample project.

    Til then, could you please tell me which clients you use? (so which browser)

    Greetings
    marci4

  2. marci4 commented on May 2, 2017

    @marci4
    Collaborator

    Hello @Irahe,

    I looked into your project and for me it works fine.

    The problem may be your self signed certificate.

    Did you go to https://localhost:8283 and told your browser to trust the certificate? (wss server has to run)

    Greetings
    marci4

  3. Irahe commented on May 2, 2017

    @Irahe
    Author

    Hello @marci4 , thank you for your fast response!

    Im using firefox 53.0 (32bits) for my tests. and i already have gone to https://localhost:8283 and accepted my certificate.
    What i cant understand is that if the problem is with my certificate, why some times it can connect correctly?

    The client im testig with is from websocket.org. it is on this link: http://www.websocket.org/echo.html.

    Can you tell me step by step how i must configure my setup so it works for me too?

    Thank you =*

  4. marci4 commented on May 2, 2017

    @marci4
    Collaborator

    Hello @Irahe,

    this is interesting. This problem occurs for me as well in firefox, but not in chrome.
    It is also limited to localhost, since I was able to connect to my production wss.

    Just to clear some things up, your client is firefox.
    The websocket.org website just provides an easy interface for the javascript implementation below.

    Gonna test it against other implementations of websocket servers and gonna keep you updated.

    Greetings
    marci4

  5. self-assigned this
    on May 2, 2017
  6. Irahe commented on May 2, 2017

    @Irahe
    Author

    Hello there, @marci4 ,

    Thank you again for your immediate response! This is really getting interesting.
    Im getting a Let's Encrypt certificate for my production domain, and so ill try to apply it to a test server on a subdomain there...
    I hope it works...

    I keep you posted!

    Best wishes,
    Irahe Kasprzykowski.

  7. marci4 commented on May 2, 2017

    @marci4
    Collaborator

    Ok here is my current status:

    SSC = Self signed certificate
    LE = Let's Encrypt

    Test case echo.websocket.org SSC:

    • Internet Explorer 11.1066 ERROR Security error
    • Firefox 53.0 ERROR Sometimes doesn't work (like 75% are fine)
    • Edge 38.14393 ERROR Security error
    • Chrome 59.0.3071.29 PASS

    Test case local file SSC:

    • Internet Explorer 11.1066 PASS ALWAYS
    • Firefox 53.0 ERROR Sometimes doesn't work (like 75% are fine)
    • Edge 38.14393 PASS Cannot get the browser to trust the certificate
    • Chrome 59.0.3071.29 PASS

    Test case local file LE:

    • Internet Explorer 11.1066 PASS (After not checking for revoke server)
    • Firefox 53.0 ERROR Sometimes doesn't work (like 95% are fine)
    • Edge 38.14393 PASS (After not checking for revoke server)
    • Chrome 59.0.3071.29 PASS

    Having TcpNoDelay set to false!

    I also was able to connect to your server without problems.

    Do you really need TCP_NODELAY set to true?

    Greetings
    marci4

  8. marci4 commented on May 2, 2017

    @marci4
    Collaborator

    Hello @Irahe,

    as mentioned above, do you really need tcpNoDelay set?
    It does cause additional stress for the cpu and network, and I think it could be the main reason for the problems.
    It is the only difference between your and my server.

    Greetings
    marci4

  9. Irahe commented on May 2, 2017

    @Irahe
    Author

    Hi, @marci4 ,

    I have disabled TCPNoDelay on the chatserver at my domain.
    However, my problems with Firefox and other naughty browsers other than chrome keep happening.
    In Firefox, if i connect, disconnect and try to reconnect, it just does nothing for a while, then times out.

    Why is Firefox so unrighteous? LOL...

    Greetings,

    Irahe Kasprzykowski

  10. zhoulifu commented on May 3, 2017

    @zhoulifu
    Contributor

    Hey guys, I've test this issue using websocket.org with a netty websocket server, it works fine with firefox as the same as chrome. I believe this problem has nothing to do with the self-signed certificate.

    Since it's sometimes failed to connect to server due to timeout, is it possible that this problem was caused by some resources leak?

  11. Irahe commented on May 3, 2017

    @Irahe
    Author

    @zhoulifu , thank you for the advice.
    I'll take a look at netty lib. However a already have made a cross-solution, proxying wss:// to ws:// in apache server, this way i can still have a https connection and a ws one.

    =D

  12. zhoulifu commented on May 3, 2017

    @zhoulifu
    Contributor

    @Irahe Glad to hear you've solved your problem.
    But it will have performance effect I think because apache needs to hold extra socket for every ws connection. Just mentioning :)

  13. marci4 commented on May 3, 2017

    @marci4
    Collaborator

    Could be related to #385 and #160

  14. marci4 commented on May 3, 2017

    @marci4
    Collaborator

    It actually is related to #385.

    Check out http://stackoverflow.com/a/30760134 for a more detail explanation.
    TL;DR java doesn't support TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 and firefox requests this.

    I quess I gonna patch this directly.

    Greetings
    marci4

  15. added 2 commits that reference this issue on May 3, 2017
  16. added this to the Release 1.3.4 milestone on May 3, 2017
  17. Irahe commented on May 3, 2017

    @Irahe
    Author

    @marci4 , FANTASTIC!
    The 1.3.4 is already available? I can just download the source and rebuild?

    Thank you guys again!

    Irahe Kasprzykowski

  18. marci4 commented on May 3, 2017

    @marci4
    Collaborator

    Hello @Irahe,

    you can build the jar directly from the sources.
    1.3.4 will not be around for at least the next 2 weeks probably a bit more. (Don't wanna go be at version 1.33.7 at the end of the year ;) )

    Greetings
    marci4

  19. Irahe commented on May 3, 2017

    @Irahe
    Author

    @marci4 ,

    The changes needed are already at the source in here( https://github.com/TooTallNate/Java-WebSocket) or i should go to your personal fork at (https://github.com/marci4/Java-WebSocket-Dev)?

    Thanks,

    I hope the 2.0 reaches us soon! =D

  20. marci4 commented on May 3, 2017

    @marci4
    Collaborator

    Hello @Irahe,

    no I already merged them into this repository.

    hahaha probably not ;)

  21. Irahe commented on May 3, 2017

    @Irahe
    Author

    @marci4 and @zhoulifu ,

    Thank you for your help!
    I just imported the new lib into my mais project and it worked like a champ!
    You can tag this issue as FIXED LIKE A BOSS... XD

    tausend dank!,
    Irahe Kasprzykowski

  22. marci4 commented on May 3, 2017

    @marci4
    Collaborator

    Happy to hear that!

    Closing issue.
    Greetings
    marci4

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions