Elixir channels with mobile devices

Hi all, first of all I have to say sorry for my bad english, this is not my native language.

I am developing a web game with Phoenix, the flow of the game is like this:

The player1 enter the game and create a room with an id (the name of the room)
Player2 joins the created room
And the game starts.

Besides of the rules of the game, when each socket of the channel is created, I set a timeout function and ping every 5 seconds the client and I send the server again a pong message.
This “ping:pong” works perfect with my cellphone, a bunch of netbooks and another devices, but sometimes when I try with an Samsung Galaxy S3 Tablet, it fails and not receive the ping message for a number of seconds (sometimes like 10 or more) and then it sends at the sametime.

I am using the Chrome browser of the tablet, I don’t remember right now the version… but this could the problem?, there is a way to debug it?.

In addition, and maybe I have to open another topic, there is a way when a user is disconnected that the other player gets notified and closes his own websocket and doesn’t try to reconnect.

Many many thanks, and again… sorry for my bad english.

1 Like

Do you have this problem over mobile network or your home internet connection?

Latency in mobile networks is quite unpredictable, and as long as you don’t have a more ore less constant stream of data (which your user probably won’t want!) you’ll have high latency due to some very nasty routing, caching, and proxying stuff happening in the networks.

I do know about some networks that hold some packages back for up to 10 seconds, to consolidate them with others that go roughly the same direction, before splitting them up somewhere in the middle, especially when that package would need to cross some foreign networks. It’s everything about cost here…

And the bad news: Since the package is still delivered at full speed the user is not able to complain about anything, since providers only guarantee bandwith, not latency…

3 Likes

Hi, thanks for the quick response.

All the devices are in the same home network, over wifi, not a mobile connection.
I think that the problem is with browser, but I don’t know how to debug it.

I am trying that ugly quickfix of disconnecting when the other player when the laggy one doesn’t respond whitin some time, but I can’t find the way of disconnecting the websocket.

Thanks again.