delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

wss error handshake #146

Open mi4uu opened 6 years ago

mi4uu commented 6 years ago

Hi, I have big problem. I cant connect on wss. this is what i got on onException:

meteor: exception: java.lang.Exception: com.neovisionaries.ws.client.WebSocketException: Failed to get the input stream of the raw socket: Handshake failed

and this is how I'm connecting to my server:

    mMeteor = new Meteor(this, "wss://beholder.com.pl/websocket");

    // register the callback that will handle events and receive messages
    mMeteor.addCallback(this);

    // establish the connection
    mMeteor.connect();

best Regards Mike

ocram commented 6 years ago

Failed to get the input stream of the raw socket: Handshake failed

I think the message of this com.neovisionaries.ws.client.WebSocketException has been pretty clear, especially the last part. The question is then why the handshake has failed.

Your sequence of calls and your backend URL look good, and the server’s response is fine too – at least temporarily, perhaps it was different back when this failed.

So if you connect using ws instead wss, everything works without problems? Can you check which Meteor version you’re using?

theshook commented 6 years ago

Hi, if I try on the other android device it works fine some other device send me handshake fail

ocram commented 6 years ago

@theshook What are the exact Android versions of the respective devices?

theshook commented 6 years ago

If I try on samsung s5 lollipop OS then the error will come out, but if I try on the zenfone3 Oreo there is no error

ocram commented 6 years ago

@theshook That might mean Android 5 with its TLS stack is too old. Can you try Android 6 or 7 perhaps? Apart from that, can you check what this tool does say for Android 5 vs Android 7 in the “Handshake Simulation” section? What is the provider of your TLS certificate? Could it be that Android 5 does not trust the certificate while Android 8 does?

theshook commented 6 years ago

hi! I'm using meteor-now to deploy my application. yes, I tried on other android version and it works fine android 7. Is there other solution regarding my problem? meteor-now uses https://zeit.co/ and if you deploy a website there for free it ends with ".now.sh" by the way I used the tool that you include in your comment and here are the results image

theshook commented 6 years ago

image

ocram commented 6 years ago

@theshook Thanks! It seems this is because the server does not support TLS 1.0 or because it lacks the cipher suites that Android 5 supports. Maybe this helps. Alternatively, you could fork the library and its sample and check if you can connect if you modify WebSocketFactory and its SSL/TLS settings as described here.

rizwan321 commented 6 years ago

has any one found the solution. i am getting the same error. i am trying app on nexus 5 having OS 6.0 marshmallow

ocram commented 6 years ago

There’s certainly one thing you could all do in order to help solve this issue for everybody:

TakahikoKawasaki/nv-websocket-client is the underlying WebSocket library that we’re using. You could create a new Android project, include that WebSocket library, and build a basic and very simple Activity that connects to your server using wss. You should specifically try versions 2.3 and 1.31 of that library. I’m afraid there’s nothing more we can do here. Sorry!