Websockets, Android and Phonegap

Questions, FAQ, Feature Requests and Troubleshooting for Airconsole

Moderator: sergey

msabatini
Posts: 11
Joined: Sat Jun 21, 2014 2:13 am

Websockets, Android and Phonegap

Postby msabatini » Mon Jun 30, 2014 10:35 pm

Hi, I know that mine is a very particular situation, but I'm asking if anybody has ever had to do with programming Phonegap webapps with websocket communication to Airconsole.
The situation is:
if I run the websockets Airconsole demo in an android phone starting from chrome browser, after having transferred .html and .js file onto the phone and opening the .html file by using file:///<path to the html file>, and after having connected in wi-fi to the airconsole, everything is ok.
Then I try to package a webapp with phonegap, and, using the cloud compiler build.phonegap.com after having configured the websocket plugin available, I can build an apk that I can install to the smartphone. The webapp so built uses the android webview component, that, itself, seems to be not providing websocket support, so the plugin comes to help.
But the connection isn't working, and it stops just as soon as
this.websocket = new WebSocket(uri, protocol);
is called in the connect function. As I only use console logs to debug the app, I cannot know why the call is failing, I can only see that the last log is the one before that call.
Thank you for any help and sorry for the very strange situation, but I think it may occur to someone else so I posted the question.
Bye

simon
Site Admin
Posts: 158
Joined: Mon Jun 06, 2011 2:48 pm

Re: Websockets, Android and Phonegap

Postby simon » Tue Jul 01, 2014 9:43 am

Hi

Were looking at an SDK extension to support PhoneGap. Were guessing that the Websocket support in PhoneGap uses a slightly different syntax than that used in IE/Firefox/Chrome which is probably causing the issue you are facing. Will have a look and see how easy it is to support.

Thanks
Simon Hope

msabatini
Posts: 11
Joined: Sat Jun 21, 2014 2:13 am

Re: Websockets, Android and Phonegap

Postby msabatini » Tue Jul 01, 2014 7:04 pm

Hi Simon
thanks for your help, I just wanted to add this information: I packaged an app with phonegap that makes only a connection to http://www.websocket.org/echo.html and it doesn't work, so this issue is definitely due to the android webview component that currently (at least for 4.3.x and before) doesn't support websockets. I verified that from 4.4.x that app is working, as webview is chrome-based, so it does support websockets.
That SDK extension you were talking about could be some sort of workaround?
Thank you

msabatini
Posts: 11
Joined: Sat Jun 21, 2014 2:13 am

Re: Websockets, Android and Phonegap

Postby msabatini » Thu Jul 03, 2014 3:31 am

Update: I managed to have the phonegap websocket plugin (https://github.com/mkuklis/phonegap-websocket) working, but there's a strange behaviour, even in the echo app I packaged: the connection is established, the test message is sent, but nothing is received.
But, once again, it's and android < 4.4 issue with websockets, you can try even going with chrome to http://www.websocket.org/echo.html: receive doesn't work. It's not related to airconsole, but I will keep you up to date just in case anyone has the same problems.

Update: it seems that wss:// connection works correctly.

Update: wss works correctly with the echo test in http://www.websocket.org/echo.html, doesn't work with airconsole.
If I won't manage to find a solution, I will write a new thread.


Return to “Airconsole”

Who is online

Users browsing this forum: No registered users and 99 guests