eclipse / paho.mqtt.android

MQTT Android
Other
2.89k stars 865 forks source link

Error: Has leaked IntentReceiver org.eclipse.paho.android.service.AlarmPingSender #431

Open darlandc1998 opened 3 years ago

darlandc1998 commented 3 years ago

Please fill out the form below before submitting, thank you!

Android API Version Bug Seen on:

Android Version Bug Seen on: compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2');

Please also check that if you have found the bug in the Release version (1.1.1) that you check that it also exists in the Snapshot (1.1.2-SNAPSHOT) before raising a bug.

Description of Bug:

Hello, I created a notification service that uses an MqttAndroidClient, when starting MainActivity.class I start the notification service (startService) that is running in the background and in the foreground, when calling onDestroy of that same activity (MainActivity.class) to stop notification service (stopService), and within the notification service onDestroy I stop running MqttAndroidClient, however when I run the methods to stop running, the following exception is thrown:

Service org.eclipse.paho.android.service.MqttService has leaked IntentReceiver org.eclipse.paho.android.service.AlarmPingSender$AlarmReceiver@b2f2c97 that was originally registered here. Are you missing a call to unregisterReceiver ()?

I perform the following methods to stop MqttAndroidClient from running:

client.unregisterResources();
client.close();
client.disconnect(0);
client.setCallback(null);

Any idea what could be causing this?

Console Log output (if available):

2020-09-06 16:35:32.250 12888-13124/com.example.ktrine D/AlarmPingSender: Unregister alarmreceiver to MqttServicepaho62240772986001
2020-09-06 16:35:32.257 12888-12888/com.example.ktrine E/ActivityThread: Service org.eclipse.paho.android.service.MqttService has leaked IntentReceiver org.eclipse.paho.android.service.AlarmPingSender$AlarmReceiver@b2f2c97 that was originally registered here. Are you missing a call to unregisterReceiver()?
    android.app.IntentReceiverLeaked: Service org.eclipse.paho.android.service.MqttService has leaked IntentReceiver org.eclipse.paho.android.service.AlarmPingSender$AlarmReceiver@b2f2c97 that was originally registered here. Are you missing a call to unregisterReceiver()?
        at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1360)
        at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1141)
        at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1436)
        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1397)
        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1385)
        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:609)
        at org.eclipse.paho.android.service.AlarmPingSender.start(AlarmPingSender.java:72)
        at org.eclipse.paho.client.mqttv3.internal.ClientState.connected(ClientState.java:1041)
        at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:882)
        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:118)
        at java.lang.Thread.run(Thread.java:764)
Alexminator99 commented 3 months ago

Im also having the same error. Any updates on this?

CrazyMo commented 2 months ago

 ,,发自我的手机-------- 原始邮件 --------发件人: Alexminator99 @.>日期: 2024年4月4日周四 10:37收件人: "eclipse/paho.mqtt.android" @.>抄送: CrazyMo @.>, Comment @.>主 题: Re: [eclipse/paho.mqtt.android] Error: Has leaked IntentReceiver org.eclipse.paho.android.service.AlarmPingSender (#431) Im also having the same error. Any updates on this?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>