Pregunta

I am developing an application with Phonegap and I am using websocket with AutobahnJS for the client application.

The remote websocket server is developed using PHP and Ratchet and runs over SSL, so I use wss:// for the connection.

The application runs well in the emulator (Android 4.4.2), but there is no way to make the connection to the websocket server using a real device that runs Android 4.0.4. The onOpen callback doensn't fire, only the onClose is called.

this.conn = new ab.Session(
  this.wsUri,
  function() { that.onOpen() },
  function() { that.onClose() },
  { // Additional parameters, we're ignoring the WAMP sub-protocol for older browsers
    'skipSubprotocolCheck': true
  }
);

To make the application work in the emulator I needed to install the websocket plugin.

So the question is:

is there any chance to use Autobahn and Websocket run on a device that runs Android 4.0.4?

Thanks in advance!

¿Fue útil?

Solución

Beginning with Android 4.4, WebView is based on Chromium (version 30), and includes native support for WebSocket.

Older versions of Android have WebView based on older version of WebKit and (as far as I know) lack support for native WebSocket: http://jimbergman.net/webkit-version-in-android-version/

Which means: you either need to use a WebSocket Plugin for Phonegap to add WebSocket to WebView OR wait for AutobahnJS finish the HTTP longpoll based fallback (under development) - and use a WAMP v2 server that supports WAMP-over-longpoll.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top