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

InlineClient模式下服务端订阅问题,Inline subscription does not support shared subscriptions. #385

Open
terry831010 opened this issue Apr 12, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@terry831010
Copy link

作者大神你好,目前使用mochi-mqtt库时,遇到两个疑问:
1、当服务端订阅topic与客户端订阅的topic一致时(如: test/# ),如果所有订阅的客户端全部disconnect后,客户端重新上线,则服务端的订阅收不到消息,看起来像客户端的离线造成了所有相关的topic全部取消了订阅

2、服务端似乎无法订阅 $SHARE/xy/iot/gateway 这样的共享topic。

服务端创建实例代码如下:
mqttServer := mqtt.New(&mqtt.Options{
Capabilities: &mqtt.Capabilities{
ReceiveMaximum: 10,
MaximumSessionExpiryInterval: 3600,
Compatibilities: mqtt.Compatibilities{
ObscureNotAuthorized: true,
PassiveClientDisconnect: true,
AlwaysReturnResponseInfo: true,
},
},
ClientNetWriteBufferSize: 4096,
ClientNetReadBufferSize: 4096,
SysTopicResendInterval: 10,
InlineClient: true,
})

@werbenhu werbenhu added the bug Something isn't working label Apr 12, 2024
@werbenhu
Copy link
Member

werbenhu commented Apr 12, 2024

1、当服务端订阅topic与客户端订阅的topic一致时(如: test/# ),如果所有订阅的客户端全部disconnect后,客户端重新上线,则服务端的订阅收不到消息,看起来像客户端的离线造成了所有相关的topic全部取消了订阅。inline subscribers do not receive messages after all non-inline clients unsubscribe

这个问题存在,即将修复。This issue exists and will be addressed soon.

2、服务端似乎无法订阅 $SHARE/xy/iot/gateway 这样的共享topic。It seems that the server cannot subscribe to shared topics like $SHARE/xy/iot/gateway

这个问题不存在,你订阅$SHARE/xy/iot/gatewa 其中xy是group,你发布iot/gatewa就可以收到消息了,参考:共享订阅介绍与示例 This issue does not exist. You can subscribe to $SHARE/xy/iot/gateway, where xy is the group, and then publish to iot/gateway to receive messages.

@werbenhu werbenhu changed the title InlineClient模式下服务端订阅问题 InlineClient模式下服务端订阅问题,inline subscribers do not receive messages Apr 12, 2024
@terry831010
Copy link
Author

感谢你对问题一的修复。 今天针对问题二再次验证,确定服务端订阅的共享topic: $SHARE/xy/iot/gateway ,客户端publish到iot/gateway,是无法收到消息的。 这里需要说明一点:我通过注册一个hook,在hook的OnPublish、OnPublished中却又是可以收到,但是在服务端的server.Subscribe里并没有收到任何数据。 当我把服务端订阅的topic改成iot/gateway,又可以收到消息了。

@werbenhu
Copy link
Member

werbenhu commented Apr 15, 2024

@terry831010 内联订阅暂时好像不支持共享订阅,服务端本身也有需要共享订阅之前确实没考虑到还会有这种场景。

@werbenhu
Copy link
Member

werbenhu commented Apr 15, 2024

@terry831010 为什么要在内联订阅中使用共享订阅呢,你能不能详细描述下你的使用场景?我看看是不是可以通过其他方案解决你的问题,I've created a new discussion about this issue. You can track the latest progress via #387.

@terry831010
Copy link
Author

你好,目前这个需求不是很强烈,我们考虑订阅不同的主题来规避。
关于场景:
系统在设计阶段是这样考虑的:服务端订阅某个主题消费数据,在外围有一个业务系统,也需要订阅相同的主题消费。此时,就需要与服务端共享订阅此主题了。

@werbenhu werbenhu changed the title InlineClient模式下服务端订阅问题,inline subscribers do not receive messages InlineClient模式下服务端订阅问题,Inline subscription does not support shared subscriptions. Aug 13, 2024
@werbenhu werbenhu added enhancement New feature or request and removed bug Something isn't working labels Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants