Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mqtt client receives msg with null topic in some cases #1503

Closed
zhengguoxin opened this issue Jul 7, 2022 · 8 comments
Closed

mqtt client receives msg with null topic in some cases #1503

zhengguoxin opened this issue Jul 7, 2022 · 8 comments
Labels

Comments

@zhengguoxin
Copy link

In most cases, mqtt client can receive the subscribed topic, but in some cases, mqtt client receives messages with null topic. I can reproduce this situation by trying to hibernate the server and then resume it.

But I don't know how to solve this problem when the received topic is null

image

@doc-han
Copy link

doc-han commented Jul 7, 2022

You will need to first figure out whether the null value is caused by the broker or the client library.

@zhengguoxin
Copy link
Author

This is not caused by the broker, because when receive null topic, other clients can receive it normally. But when I restart nodejs, this mqtt client can receive correct topic value

@tennessine
Copy link

你用的什么broker,怎么能跑出来null topic

@zhengguoxin
Copy link
Author

你用的什么broker,怎么能跑出来null topic

和broker无关,用的是emqx的。我找到规律了,当mqtt连接成功后,如果后续的代码有一个长时间的cpu密集运算,比如一个耗时很长的for循环,那么在循环中,实际上mqtt客户端没有和broke连接了(因为cpu被分配给循环)。等循环结束后,mqtt会自动重连成功,但是这个时候虽然可以接收信息,但是topic居然是null。

既然能收到消息,说明topic寻址是正常,而回调中topic为空,应该是这个mqtt的bug导致。

这个问题在部分场景下可以利用 v5版本的 properties特性来携带topic,但是这个场景不能解决所有的问题,

希望有大侠能解决这个bug,谢谢

@github-actions
Copy link

This is an automated message to let you know that this issue has
gone 365 days without any activity. In order to ensure that we work
on issues that still matter, this issue will be closed in 14 days.

If this issue is still important, you can simply comment with a
"bump" to keep it open.

Thank you for your contribution.

@github-actions github-actions bot added the stale label Jul 15, 2023
@robertsLando
Copy link
Member

MQTT 5.0.0 BETA is now available! Try it out and give us feedback: npm i mqtt@beta. It may fix your issues

@github-actions github-actions bot removed the stale label Jul 22, 2023
Copy link

This is an automated message to let you know that this issue has
gone 365 days without any activity. In order to ensure that we work
on issues that still matter, this issue will be closed in 14 days.

If this issue is still important, you can simply comment with a
"bump" to keep it open.

Thank you for your contribution.

@github-actions github-actions bot added the stale label Jul 21, 2024
Copy link

github-actions bot commented Aug 4, 2024

This issue was automatically closed due to inactivity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants