-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Integrated an SSLSocketChannel class that allows wss support #101
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
Conversation
…ent errors: see http://code.google.com/p/android/issues/detail?id=22970). Added the SSLSocketChannel file, and modified the WebSocketImpl to support its use. Added an example that shows how it would be used. Rebuild the distribution output.
@fomojola thank you very much! I will approach "merging" as soon as i can. |
@fomojola how did you make your browsers accept the certificate? |
You either have to use a properly chained cert or it is actually moderately painful: you basically have to visit the IP address using a regular https URL. The browser will prompt you with the usual security warnings and you have to accept the warning and create a security exception, and then it works after that. Very sub-optimal, but unfortunately no options. |
|
||
class WebSocketSource extends WebSocketServer | ||
{ | ||
private WebSocket handle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fomojola I am just testing around with ssl trying to simplify things if possible: 98f4a3c
And i am not sure what the 'handle' is for...? It seems to limit the number of simultaneous connections...
But even when i remove the handle as you see in my code my firefox somehow fails to create more that one ssl connection to the example server at a time.
I am probably missing some basic mechanic...
Do you have an explanation for that behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right: handle was basically a remnant of my application that made it into the test file, since in my app I only allowed 1 connection at a time.
Creating multiple connections should be just fine: just strip out all references to handle and use arg0. I'm not sure what the default backlog is: I think it is 50 or something, but the base WebSocketServer doesn't set it when calling bind, so there may be something there that prevents multiple connections.
Does the WebSocketClient.java support wss? If yes, how to configure this? |
WebSocketClient.java and WebSocketServer.java do not care if you use ws or wss. SSLServer.java shows how to do that. Please also consider #111 and https://github.com/TooTallNate/Java-WebSocket#wss-support. |
Hello, |
I agree with @mparis, it would be great if you could update the outdated maven central release. Lots of developers prefer to pull down their dependencies from there. |
Actually yes, I too agree with @blunden, can you guys please update the maven central. |
@mfsi-ankitb The issue might be that it still has problems with working on both 5.0 and earlier versions. See #293 |
@blunden I tried using Java-WebSocket with the latest source code, and it is working for me on lollipop with WSS (using default SSLcontext). |
@mfsi-ankitb Oh, really? Did you confirm that it works with earlier Android versions too? I personally switched to a different lib for that issue. I know of others who would be interested to know that it has been fixed though. |
@blunden Yes, the connection opens and I am able to send and receive messages (checked in 5.0 and 4.1.1). But, facing some problems like connection breaks (doesn't connect back) when Internet Connectivity drops and reconnect again. And I can't connect back with same client once disconnect is triggered. |
@mfsi-ankitb Thanks for the confirmation! Yeah, you will need to recreate the WebSocket related objects. That seems to be the case in many WebSocket libraries. Perhaps you can reconnect in some onWebSocketError-like method? |
I integrated an SSLSocketChannel class (taken from the jFxp project at http://jfxp.sourceforge.net/ with permission by the author, Alexander Kout) and modified the WebSocketImpl to allow the use of that instead of a standard SocketChannel.
Also added a simple SSL example that uses a self-signed certificate. The example/SSLServer.java includes a really simple test case that uses a keystore generated using keytool (the keytool syntax is present in that file as a comment, as well as the keystore loading code required).