Closed ddobric closed 1 year ago
Are SendTopic and RcvTopic the same? Have you subscribed the client with that topic before subscribing to the observable? What is the server being used? Is it System.Mqtt.Server too or a third party?
Thanks!
It looks as this would happen if publisher and receiver use same ClientID. This is for sure not a production case (it happened during invalid unit test configuration), but I'm not sure if it is correct.
The second connection using the same client ID should cause the previous one to be forcefully disconnected, according to the spec. I believe that is currently the case, right @mauroa?
It does not behave this way. Second does not cause the first one to be disconnected. First one is continuously receiving the message. To me this does not look correct.
Can you please try changing the Quality of Service to a lower value? (either 0 or 1). You are using QoS 2 in your samples (MqttQualityOfService.ExactlyOnce). It’s just to discard an issue with it. Thanks.
Are you using this MQTT implementation for both client and server? If so, can you provide the full failing unit test so we can repro?
Thanks!
As I mentioned, the reason was using of same ClientID for publisher and subscriber.
Hi, I am testing the server and the client (this implementation), and have a similar issue. When I suscribe to a topic, and then send only one message to that topic, the message is received and received infinitely at intervals for about 5 seconds. It is the same client, in the same app. First I suscribe to the topic and then send the message.
If I send the message from another client, the message just arrives once, but sending it from the same client makes this weird behavior...
Thanks a lot!
Hi all, I fixed the issue staring the server with the same configuration as the client (QoS 2), as I was not introducing any parameter in the MqttServer.Create() method.
Now it seems to work great! :)
Good job 👍 Which nuget version contains the fix?
I think it still not working correctly on version I get from nuget in visual studio. I still get one topic after a while. And dont get nothing on the beginning. And when I use Guid as ClientId it is not working at all. So I came back to M2Mqtt
By following you example, I have implemented subscriber as shown below:
this.m_MqttClient.MessageStream .Where(msg => msg.Topic == this.m_RcvTopic) .Subscribe(async msg => {
await msgReceiver?.Invoke(msg.Payload);
The message is sent by using this code:
await this.m_MqttClient.PublishAsync(new MqttApplicationMessage(this.m_SendTopic, message), MqttQualityOfService.ExactlyOnce);
The message is correctly sent and received, but receiving of the same message does not stop. The message is received over and over again. What is the correct way to reliably complete receiving of the message?
Thanks