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

wss not working with cordova 3.4.0 #43

Open
zwz opened this issue Apr 17, 2014 · 8 comments
Open

wss not working with cordova 3.4.0 #43

zwz opened this issue Apr 17, 2014 · 8 comments

Comments

@zwz
Copy link

zwz commented Apr 17, 2014

  1. create a cordova project, and install the plugin
  2. copy the example/websocket.html comes with the plugin, and replace index.html of the project
  3. modify the function init() in index.html as:
    function init() {
    var socket = new WebSocket("wss://echo.websocket.org");
    socket.onopen = function(){
    alert("opend");
    };
    socket.onclose = function(){
    alert("closed");
    };
    }
  4. build the project and run it on android phone, it says "closed"
  5. but if set the "onload" attribute of the body element in index.html to "init() " and open it directly in chrome, it says "opend"!

I also tried ripple to test the project. Hope the result is helpful:

  1. install ripple
  2. emulate the project in chrome with the command "ripple emulate"
  3. it just shows a dialog saying:
  • WebSocket.connect

We seem to be missing some stuff :(

What is kinda cool though you can fill in the textarea to pass a json object to the callback you want to execute

@julisman
Copy link

julisman commented Aug 9, 2014

i use cordova 3.4.0 and working :)

@Tarang
Copy link

Tarang commented Aug 9, 2014

Im also having a problem here. Its just with SSL/wss. Version 3.5.0

@ghost
Copy link

ghost commented Sep 1, 2014

I am also experiencing this issue

@mkuklis
Copy link
Owner

mkuklis commented Dec 15, 2014

guys please share your index.html with me on jsfiddle or somewhere else so I can take a closer look.

@zwz
Copy link
Author

zwz commented Dec 16, 2014

I think maybe this is related to the ssl cert.
@julisman Where did you get your ssl cert?

@trygve-lie
Copy link

I'm experiencing the same issue. My app is on SSL also.

What I got so fare is that if I use the following code (actually tried it in my app):

function init() {
    var socket = new WebSocket("wss://echo.websocket.org");
    socket.onopen = function(){
        alert("opend");
    };
    socket.onclose = function(){
        alert("closed");
    };
}
document.addEventListener("deviceready", init, false);

It does open a connection. If I switch to my own domain, it does not work and the closed alert will fire. This does not work:

function init() {
    var socket = new WebSocket("wss://m.ladestasjoner.no/primus/");
    socket.onopen = function(){
        alert("opend");
    };
    socket.onclose = function(){
        alert("closed");
    };
}
document.addEventListener("deviceready", init, false);

I use primus and ws for web socket transport. If I run the web socket code above which does not work in ex Chrome, it does connect and the opened alert fire. Iow, the example does work from a browser with web socket support but not from our phonegap app with this plugin.

To feed the theory about certificate problems: our certificate is a RapidSSL SHA256 CA - G3 certificate. websockets.org seems to be using a Go Daddy Secure Certificate Authority - G2. There is also a difference between TLS versions on our servers (node.js) and the one a websocket.org. Can this problem be bound to TLS versions?

I had this working before we had to update our certificates due to them expiring.

@trygve-lie
Copy link

I was able to debug this a bit more (and found a workaround for me). Our servers are at the moment hosted at nodejitsu and there the app is exposed on our own domain and on an additional *.jit.su domain owned by nodejitsu. The *.jit.su domain which our app is exposed at is available at SSL but with a SSL certificate owned by nodejitsu (its a DigiCert Global Root CA).

So, my server app code is running on two domains with two different certificates. I am able to connect to the *.jit.su domain over SSL, but not able to connect to the same app on my own domain over SSL.

iow: this does not work:

function init() {
    var socket = new WebSocket("wss://m.ladestasjoner.no/primus/");
    socket.onopen = function(){
        alert("opend");
    };
    socket.onclose = function(){
        alert("closed");
    };
}
document.addEventListener("deviceready", init, false);

This does work:

function init() {
    var socket = new WebSocket("wss://ladestasjoner-mobile.jit.su/primus/");
    socket.onopen = function(){
        alert("opend");
    };
    socket.onclose = function(){
        alert("closed");
    };
}
document.addEventListener("deviceready", init, false);

Any ideas what can be causing this?

@shadimsaleh
Copy link

i used mkuklis/phonegap-websocket like example but work on genymotion but when i install in my android mobile it is not install (App not install)

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

No branches or pull requests

6 participants