Skip to content

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

Merged
merged 2 commits into from
Jul 12, 2012

Conversation

fomojola
Copy link

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).

Femi Omojola added 2 commits June 10, 2012 04:12
…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.
@Davidiusdadi
Copy link
Collaborator

@fomojola thank you very much!

I will approach "merging" as soon as i can.

Davidiusdadi added a commit to Davidiusdadi/Java-WebSocket that referenced this pull request Jun 17, 2012
@Davidiusdadi
Copy link
Collaborator

@fomojola how did you make your browsers accept the certificate?

@fomojola
Copy link
Author

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.

@Davidiusdadi Davidiusdadi merged commit 0a4a98c into TooTallNate:master Jul 12, 2012

class WebSocketSource extends WebSocketServer
{
private WebSocket handle;
Copy link
Collaborator

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?

Copy link
Author

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.

@vikasjayaram
Copy link

Does the WebSocketClient.java support wss? If yes, how to configure this?

@Davidiusdadi
Copy link
Collaborator

WebSocketClient.java and WebSocketServer.java do not care if you use ws or wss.
The WebSocketFactory allows to use custom websocket and channel objects and can therefore be used put an ssl channel in place.

SSLServer.java shows how to do that.

Please also consider #111 and https://github.com/TooTallNate/Java-WebSocket#wss-support.

@mparis
Copy link

mparis commented Apr 11, 2014

Hello,
I am working with WSS and it works well ;).
I have got it downloading the source code and installing it in local with maven, but I want to use Maven Central dependency (http://mvnrepository.com/artifact/org.java-websocket/Java-WebSocket).
The problem is that the current version is 1.3.0 and WSS is available in 1.3.1-SNAPSHOT version.
As I see, the code is stable since few months ago. So, is it possible to deploy a new release to Maven Central?

@blunden
Copy link

blunden commented May 17, 2015

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.

@mfsi-ankitb
Copy link

Actually yes, I too agree with @blunden, can you guys please update the maven central.
I am on live project and really need to use WebSockets having WSS enabled with lollipop.

@blunden
Copy link

blunden commented Sep 11, 2015

@mfsi-ankitb The issue might be that it still has problems with working on both 5.0 and earlier versions. See #293

@mfsi-ankitb
Copy link

@blunden I tried using Java-WebSocket with the latest source code, and it is working for me on lollipop with WSS (using default SSLcontext).

@blunden
Copy link

blunden commented Sep 11, 2015

@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.

@mfsi-ankitb
Copy link

@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.

@blunden
Copy link

blunden commented Sep 11, 2015

@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?

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

Successfully merging this pull request may close these issues.

6 participants