Closed rgillan closed 10 years ago
@rgillan I think I will have to wait with this until some cases in https://github.com/TooTallNate/Java-WebSocket/ are done. In particular I would like to get this merged first: https://github.com/TooTallNate/Java-WebSocket/issues/155
Michal,
This is the one to watch: https://github.com/TooTallNate/Java-WebSocket/pull/205
This was tested a couple of weeks ago and hopefully will make it in soon. We are still trying to get to the bottom of the larger packet size failing.
/r
On 19/09/2013, at 6:27 AM, Michal Kuklis notifications@github.com wrote:
@rgillan I think I will have to wait with this until some cases in https://github.com/TooTallNate/Java-WebSocket/ are done. In particular I would like to get this merged first: TooTallNate/Java-WebSocket#155
— Reply to this email directly or view it on GitHub.
Thank you for point this one to me Rob.
On 9/18/13 6:11 PM, Rob Gillan wrote:
Michal,
This is the one to watch: https://github.com/TooTallNate/Java-WebSocket/pull/205
This was tested a couple of weeks ago and hopefully will make it in soon. We are still trying to get to the bottom of the larger packet size failing.
/r
On 19/09/2013, at 6:27 AM, Michal Kuklis notifications@github.com wrote:
@rgillan I think I will have to wait with this until some cases in https://github.com/TooTallNate/Java-WebSocket/ are done. In particular I would like to get this merged first: TooTallNate/Java-WebSocket#155
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHub https://github.com/mkuklis/phonegap-websocket/issues/17#issuecomment-24703760.
First off, thank you for this great plugin which has allowed me to connect to both ws:// and wss:// websockets in Android 4.0 and above. I haven't tested anything lower. I was able to get WSS working by modifying the CordovaClient constructor by adding this code:
//We must use a secure socket for a wss:// URI
if (serverURI.getScheme().equals("wss")) {
try {
SSLContext sslContext = null;
sslContext = SSLContext.getInstance( "TLS" );
sslContext.init( null, null, null ); // will use java's default key and trust store which is sufficient unless you deal with self-signed certificates
SSLSocketFactory factory = sslContext.getSocketFactory();// (SSLSocketFactory) SSLSocketFactory.getDefault();
this.setSocket(factory.createSocket());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Is this a reasonable solution to the problem of connecting to WSS? What would the preferred approach be to get wss:// working?
Thanks, Andy
@aburtnett I tried your code, but I am getting setSocket is undefined error. Where is it defined? Thanks
@aburtnett I am not able to get wss working using SSL certificates so am intrigued how you managed it on Android. Any help?
@aburtnett thank you for your snippet. It will be helpful to add WSS support. The recent version of Java-Websocket has changed so I will have to take another look at it. I plan to add the WSS support by the end of this week. I will probably use part of your code. Thanks again!
Do you have the latest java_websocket.jar? The WebSocketClient.setSocket() method was only added a few days ago in this commit:
Andy
@aburtnett yes I believe the current jar https://github.com/mkuklis/phonegap-websocket/tree/master/libs includes that already.
@mkuklis is it possible to update the old websocket code to work with wss? I am using Phonegap v2.5 and have loads of other plugins that work with that version. If I upgrade to PG3 then my other plugins would stop working. I trust your excellent WS plugin and would love to use it with Phonegap 2.5 with wss support. Any help? Thanks.
@aburtnett Thanks, I have not updated my Phonegap!
@mkuklis Please can you update the old 2.xx version of your WS plugin to use latest jar? Would be so useful! Thanks.
@aburtnett @mkuklis Just tried the latest jar with 2.5 of Phonegap and it works with SSL Certificates on v2.2 of Android. Tried it on v4.3 and v4.1.2 of Android. The changes @aburtnett made, works well. Thank you both!
@rgillan I just pushed a little change based on the @aburtnett's snippet which adds wss support (only known providers - not self sign). If you could give it a try and report back if it works for you that would be great.
Michal,
This is now working, thanks so much. We are using a signed certificate btw.
Cheers Rob
@rgillan cool thanks for letting me know.
Support for WSS, with a preference to selecting either WS or WSS by the prefix in the URL parameter