hannesa2 / paho.mqtt.android

Kotlin MQTT client for Android
407 stars 94 forks source link

Make the "client connected" pre-check valid #626

Closed FJEagle closed 3 months ago

FJEagle commented 3 months ago

This reverts commit 39e5ed4a5fe425d4baf6248cf582574e84656db2.

Why reverted?

The commit caused 2 problems:

Problem 1:

run in coroutine, make the "client connected" pre-check might not valid anymore when it runs, therefore the underlying sendNoWait 'client connected' check not matched causing the following exception:

image

Problem2:

run in coroutine, make the "sendToken" assignment-and-return invalid, it may always return null outside coroutine.

image

FJEagle commented 3 months ago

@hannesa2 could you help why check failed, I just revert the previous commit

hannesa2 commented 3 months ago

yes, this sendToken is an issue. Thank you for pointing this out. I try with https://github.com/hannesa2/paho.mqtt.android/pull/628 an other way to solve it

FJEagle commented 3 months ago

yes, this sendToken is an issue. Thank you for pointing this out. I try with #628 an other way to solve it

628 should have solved problem 2 ,how about problem 1?

Run in coroutine might cause the underlying sendNoWait 'client connected' check not matched, results in throwing exception(32104), and then crash.

This exception seems not able to be caught in external business when call the publish method since it runs in coroutineScope

hannesa2 commented 3 months ago

Maybe I don't really understand the issue exactly. Please can you point me to

the 'client connected' pre-check

that we'll speak about the same

FJEagle commented 3 months ago

here are two screenshots:

the 'client connected' pre-check: image

the underlying sendNoWait 'client connected' check and exception throw: image

hannesa2 commented 3 months ago

Please can you rebase to be able to merge ? I renamed confusing stuff before

FJEagle commented 3 months ago

ok, I'll do it, please wait for a while

hannesa2 commented 3 months ago

Which version are you using ?

FJEagle commented 3 months ago

Which version are you using ?

4.3.beta2

hannesa2 commented 3 months ago

https://github.com/hannesa2/paho.mqtt.android/releases/tag/4.3.beta3

FJEagle commented 3 months ago

https://github.com/hannesa2/paho.mqtt.android/releases/tag/4.3.beta3

Thanks.

But it seems there are some errors in jitpack:

image

hannesa2 commented 3 months ago

I re-triggered the build, now it's ok

image