|Connection lost on first ping after switching to wifi [message #1711599]
||Sat, 17 October 2015 23:02
| Vitalii Stakhov
Registered: October 2015
I'm using Android paho from the develop branch.|
I've set keepAlive to 15 seconds just to see log output more frequently.
Here is the behavior I see.
1. I connect using 3g
2. I see successful ping messages sent by AlarmPingSender every 15 seconds.
3. I turn on Airplane mode and see AlarmPingSender unregisters alarmreceiver.
4. I turn Airplane mode off. 3g comes back, new alarmreceiver is registered, client connected and I can see successful ping messages.
5. I turn on wifi. Right after the first ping message (which looks to be successful), alarmreceiver is unregistered and connectionLost is called. The client is disconnected and won't try to reconnect.
From what I see in logs, I make the following conclusions how paho works. It connects and sends ping messages once every keepAlive seconds. If a network changes (from 3g to wifi to lte to no connection), the client will try to reconnect.
If connection is lost while using the same network (while being on 3g for example), paho wouldn't reconnect. It will reconnect either when connect method is called explicitly or when network type switches from one type to another.
The problems I see are:
a) paho doesn't automatically try to reconnect when switching from 3g to wifi. It just invokes connectionLost and sits there without connection
b) if I invoke connect method from connectionLost so that the client is reconnected after switching to wifi it works well, but screws other places, for example, a future connect attempt (in connectionLost) may fail with the 'client is disconnecting' error and after that paho is not trying to reconnect even on network type switches.
So what is the solution for having the client connected when connection is lost after switching to wifi? Is it a bug?
Powered by FUDForum
. Page generated in 0.01609 seconds