Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebSocket support on mobile devices

For an Android multiplayer game's communication between players I'm using a WebSocket server and TooTallNate's Java library on the client side to enable WebSocket support in the Android app. So just to point it out clearly, WebSocket support in mobile browsers is not important to me.

Unfortunately, users report that they're experiencing problems such as connection failures or unreceived messages. Is that a general problem of WebSockets on mobile devices (blocked ports, firewalls, mobile Internet connection) or is that probably a flaw in the client side code?

Do you have experience with WebSocket client libraries such as the one above? I've just discovered autobahn.ws for Android - but I don't know if it's worth switching from my current library (see above).

What about WAMP? Is WebSocket technology not exactly the adequate solution so that I should use the sub-protocol (?) WAMP?

like image 539
caw Avatar asked Jan 12 '13 16:01

caw


2 Answers

Had these same errors with a bad web socket connection over certain mobile networks. Solved them by:

(1) moving ports: Moving over server and client for websocket over to the SSL port (port 443)

(2) ping keep-alive: Sending periodic "ping" messages from client to server every X seconds, and waiting for a "pong" to return from server. If server doesn't give "pong" back within Y seconds, restart the connection on client.

implementing (1) will get you most of the way there.

like image 109
Philip Fung Avatar answered Nov 04 '22 17:11

Philip Fung


Every new technology comes with a new set of problems. In the case of WebSocket it is the compatibility with proxy servers which mediate HTTP connections in most company networks. The WebSocket protocol uses the HTTP upgrade system (which is normally used for HTTP/SSL) to "upgrade" an HTTP connection to a WebSocket connection. Some proxy servers do not like this and will drop the connection. Thus, even if a given client uses the WebSocket protocol, it may not be possible to establish a connection.

like image 23
atta Avatar answered Nov 04 '22 17:11

atta