Question

Is there any way to get Android working with SockJs for socket connections in an app packaged in Phonegap? At the moment I have the following code that works on iOS but fails in Android because of the file:/// restriction for socket connections in android.

var sock = MyEnt.connect('servicename', 'http://socket.api.somewhere.be/api', {debug: true});
var entity_plays = sock.subscribe('plays');
entity_plays.on("play", function(data, msg) {
       //Do something with data
       console.log(data,msg)
}, {backlog: 10});

I have changed the service names for client privacy but as the above code works in the iOS PG version (and desktop browsers for that matter), that shouldn't matter. The MyEnt object is a small wrapper containing custom functions in the SockJS class, but again works perfectly on iOS

Any ideas?

Was it helpful?

Solution

SockJS should work correctly from phonegap. Either via native web sockets or xhr-streaming. Look for file:// in documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top