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

Add SSL (wss) support #3

Closed ocram closed 8 years ago

ocram commented 9 years ago

The Autobahn library doesn't have support for the wss protocol so either switch to another library or wait until the feature is added

ocram commented 9 years ago

Thank you very much!

My issue with that library is that it isn't as extensively tested as the original Autobahn library. So I don't really want to switch to it here in the main repository.

But we'll leave the link to your fork here as the reference for all developers who need WSS (TLS) support today. Thank you!

By the way, Autobahn even has a TLS branch. But that one does not pass their extensive test suite yet, and unfortunately it hasn't been updated in the past three years.

We may also switch to TubeSock instead, which is based on the old Weberknecht library.

elbow commented 8 years ago

Happy to find this thread, just to note that I also need TLS support for my application.

Many thanks for your effort on this library.

vlasky commented 8 years ago

Hiyas, I have successfully added SSL support to Android-DDP by replacing Autobahn with Takahiko Kawasaki's nv-websocket-client.

It has been tested successfully in Android 4.4 and upwards. It may work in earlier versions, but I haven't needed to use any Android devices with those old versions. I will share my code with Marco and see what he thinks.

isdzulqor commented 8 years ago

how to sett up server for this library, I made an android native app with this library and I use meteor for my web service. I dont remove insecure package and autopublish package. so I can Insert, delete and update without subscribe or call the method in client. but my problem is I can not connect to my localhost. I use genymotion for the android emulator. Any one can Help me, please,,, Thank you for this amazing library here is my code https://ideone.com/pXzJW8

vlasky commented 8 years ago

isdzulqor - I see one obvious error in your code. Your URL is missing "/websocket".

Instead of:

mMeteor = new Meteor(getApplicationContext(), "ws://192.168.56.1:3000");

It should be:

mMeteor = new Meteor(getApplicationContext(), "ws://192.168.56.1:3000/websocket");

isdzulqor commented 8 years ago

@vlasky Thank you man, it works.. I've tried many times, i've tried restivus too, but it's still not working,, now you save my live :D but I am still wondering about, is it possible to upload file through ddp with this library,. like picture, video etc.. any way thank you so much for this amazing library too :) ,,

ocram commented 8 years ago

Experimental support for WSS (WebSocket over SSL/TLS) is now available on a separate branch :)

Please get the latest JAR there and test WSS support with your app. Do not use it in production yet.

You'll have to remove the two parameters from your onDisconnect(...) callbacks and the minimum API level has been raised from 8 (Android 2.2) to 9 (Android 2.3).

As soon as everything has been tested and bugs have been fixed, we'll integrate this into the main branch.

Thanks for your patience, @elbow and @vlasky!

@vlasky I've taken a look at your code -- it's good and we really appreciate your work. But we feel that TubeSock is a superior WebSocket library so we'll use that instead of nv-websocket-client.

vlasky commented 8 years ago

OK, but I wouldn't poo-poo nv-websocket-client just yet - the author is actively and enthusiastically maintaining that package.

Also, I recently asked him to add support for websocket compression using permessage deflate and his response was encouraging:

https://github.com/TakahikoKawasaki/nv-websocket-client/issues/15

I presume you are aware that Meteor 1.2 recently introduced support for this. If it were supported in the DDP client, it would greatly reduce the amount of data transferred over the internet connection - very useful when clients are communicating over cellular data networks that have data usage quotas.

TubeSock doesn't appear to support this and there is no roadmap on TubeSock's page that would indicate plans for future support.

ocram commented 8 years ago

@vlasky Thanks for your thoughts!

We've worked with seven of the major WebSocket libraries that are available for Java/Android in the past. Judging stability, ease of use and overall quality, we would definitely rank those as follows:

  1. TubeSock (based on weberknecht by Roderick Baier)
  2. okhttp-ws
  3. nv-websocket-client
  4. autobahn-android
  5. Java-WebSocket
  6. AndroidAsync
  7. android-websockets

In fact, we've even built this WSS implementation with all of (1), (3), (4) and (5). TubeSock turned out to be the best library, mainly because it's super stable, with nv-websocket-client being a close contender.

What also speaks for TubeSock is:

So TubeSock is definitely what this library will be based on, starting with the next release.

But this may change again in the future, and we'll watch nv-websocket-client and the others closely.

Until then, you can of course keep using your forked version of this library that uses nv-websocket-client.

ocram commented 8 years ago

Implemented in https://github.com/delight-im/Android-DDP/commit/61109f1522f74b11a61bac48b40376ec18df6885 and 8 parent commits, and merged into the main branch :)

vlasky commented 8 years ago

Takahiko Kawasaki, the author of the websocket library nv-websocket-client, has just announced that he has implemented support for permessage deflate. I will be testing it out in my forked version of Android-DDP.

https://github.com/TakahikoKawasaki/nv-websocket-client/issues/15

ocram commented 8 years ago

@vlasky Thanks, impressive speed! As I said, we'll definitely watch that WebSocket library closely. In the meantime, developers who need support for "permessage-deflate" can probably get good support with your forked version, as soon as it's ready.

TakahikoKawasaki commented 8 years ago

@mwaclawek @vlasky

Comments from the author of nv-websocket-client (me) after reading the source code of TubeSock.

WebSocket class

WebSocketHandshake class

WebSocketReceiver class

WebSocketEventHandler interface

MessageBuilderFactory

TakahikoKawasaki commented 8 years ago

Whether a library is used by many people, maintained by a big company, already deployed in many commercial environments, does not necessarily assure its quality. For example, Adobe Flash.

From my viewpoint, the quality of TubeSock is beginners' level. Don't believe rumors about software naively, but compare source codes when you select one from among multiple choices.

See also "Which WebSocket library to use in Android app?" (StackOverflow).

ocram commented 8 years ago

@TakahikoKawasaki Thank you very much for taking the time to look at TubeSock's source code and advertising your library. Just as rumors (whatsoever) are no good indicator of a library's quality, simply adding large quantities of features at a rapid pace is not an indicator of quality, either. But as I said, we're watching your library, which has emerged as an interesting contender, closely, and may very well do the switch in the near future.