Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Support for Websockets on Android

I'm about to start a project for a client that has lots of data that needs to be real-time.

There are two mobile apps that I will be building with trigger.io, as well as a web UI, and all of these need to stay in sync.

I plan to use socket.io's WebSocket implementation with my Node.js backend for the webapp & mobile apps. This will work great on iOS and modern web browsers.

However, Android's webview does not support websockets at all. And it would simply destroy the mobile app user's data plan if socket.io used its long-polling fallback on Android.

I was wondering: is there any possibility of an implementation of Java WebSockets for trigger.io Android, then exposing that to the WebView? There is a simple implementation for phonegap

I suppose I could write a trigger.io plugin for it - but I want to be sure before I jump in to this project if this is feasible / not too hard to write a plugin for.

I used trigger.io long ago, but not since all the fanciness came out like native plugins.

like image 734
Andrew Joslin Avatar asked May 21 '13 16:05

Andrew Joslin


1 Answers

If using an HTTP fallback solution isn't an option (I'd do some calculations to determine if a streaming or long-polling solution would really "destroy the mobile users's data plan") then the best solution to add WebSocket support would probably be a trigger.io plugin.

At Pusher we used a Java wrapper in PhoneGap in order to get our JavaScript library to work. However we've since added HTTP fallback so I wouldn't recommend anybody use this now. The project is here: https://github.com/pusher/pusher-phonegap-android

The problem with the Java wrapper here (we use websocket-android-phonegap) is that it doesn't support SSL connections (if I remember correctly) and it hasn't been updated for a long time.

With that in mind when we created the Pusher Java library (which supports Android) we used the WebSocket client in Java-WebSocket because it's being actively developed and supports SSL connections. I'd recommend it.

I'd be interested to hear about the support that https://github.com/mkuklis/phonegap-websocket provides.

like image 144
leggetter Avatar answered Sep 28 '22 07:09

leggetter