eclipse / paho.mqtt.java

Eclipse Paho Java MQTT client library. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
2.13k stars 886 forks source link

Paho:Mqttv3 1.2.0: EOF Exception Connection lost #562

Open Mamathatg opened 6 years ago

Mamathatg commented 6 years ago

Below is the issue being faced, Testing Scenario Checking for continuous connection from our application to mqtt broker by pinging every 5 sec. Keep alive is set to 5 sec. Two scenarios where i am facing the issue 1) Ping response is failed and i get the Connection lost when there is a token null or wakelock held and there is Failure message Below is the log

Sending Ping at: 1529422551514 Failure. Release lock(MqttService.client.paho26505181302488):1529422551588org.eclipse.paho.client.mqttv3.MqttToken@937985d Unregister alarmreceiver to MqttServicepaho26505181302488 MqttConnection:connectionLostTimed out waiting for a response from the server Schedule next alarm at 1529422551738 Alarm scheule using setExactAndAllowWhileIdle while dosing 100 if autoreconnect Connection lost to :Timed out waiting for a response from the server (32000)

      I understand the the above scenario that didnt get a response from server at correct time

2) There is Connection lost even when there is token recieved from the server and there is success message . Please see log below Sending Ping at: 1529305957809 Schedule next alarm at 1529305962819 Alarm scheule using setExactAndAllowWhileIdle while dosing 5000 Success. Release lock(MqttService.client.paho6333640400389):1529305957965 Unregister alarmreceiver to MqttServicepaho6333640400389 Schedule next alarm at 1529305966103 Alarm scheule using setExactAndAllowWhileIdle while dosing 100 Connection lost to :Connection lost (32109) - java.io.EOFException Register alarmreceiver to MqttServiceMqttService.pingSender.paho6333640400389

    I am not able to understand reason for unregistering the alarmreciever even after success

Been working on it for past 7 weeks Please help Thanks, Mamatha

jpwsutton commented 6 years ago

Hi @Mamathatg,

It looks like this is actually for the Android Service, is that correct? Android made some changes a few years ago that restricts the ability for applications to maintain network connections when running in the background. Effectively once the OS puts the application in the background, all alarms are disabled and network connections cease, could this be what you're experiencing?

Mamathatg commented 6 years ago

Hi James, Correct, It is for Android service but the application runs always in foreground as I keep the phone connected to usb.

On Tue 24 Jul, 2018, 7:43 PM James Sutton, notifications@github.com wrote:

Hi @Mamathatg https://github.com/Mamathatg,

It looks like this is actually for the Android Service, is that correct? Android made some changes a few years ago that restricts the ability for applications to maintain network connections when running in the background. Effectively once the OS puts the application in the background, all alarms are disabled and network connections cease, could this be what you're experiencing?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/eclipse/paho.mqtt.java/issues/562#issuecomment-407421439, or mute the thread https://github.com/notifications/unsubscribe-auth/Ad1aLVskLl6iRMFlpLyfGMMzbKm9hl5Rks5uJyuUgaJpZM4VQFly .