WebSockets in WebView dropping/hanging (but not explicitly disconnecting) after a couple minutes or on switching app

444 views
Skip to first unread message

chro...@gmail.com

unread,
Mar 24, 2015, 6:40:29 PM3/24/15
to soc...@googlegroups.com
Expected result:

I have a web app that runs on websockets (SockJS) talking to a python backend. It works flawlessy in the browser (on a computer, or my phone); socket connections stay open and useful allowing for messages to be sent and received as long as the window is open/active. If you leave the window for a while the socket may disconnect, but upon returning it will promptly reconnect and load what was missed. 

Actual result:

I have cooked up a simple WebView for android which has no problem displaying the page and running the necessary javascript. Upon opening the app messages flow back and forth from client to server as expected, but then after a couple of minutes, the client keeps sending messages but receives nothing in return... It seems like the connection is being dropped but that the WebView is unaware that it has ended.

Once in a while XHR long-polling randomly kicks in (the fall back for socket connections) and then drops out.

Over all, the WebView's performance with SockJS in my case is rather inconsistent/unreliable and I'm unsure if this is something that can be over come.

Relevant code can be found here: http://stackoverflow.com/questions/29241105/android-webview-chromeclient-sockets-dropping-connections-using-xhr-falback

hasher

unread,
Mar 24, 2015, 7:01:16 PM3/24/15
to soc...@googlegroups.com
My users have same experience. Maybe exporting Websocket Java class from Android code to JS code would fixs this?
Reply all
Reply to author
Forward
0 new messages