NanoMQ: Socket Multiplexing? #1108
Replies: 13 comments
-
Hi, Thanks for submitting this detailed issue according to the template. As I just confirmed on code ver of 0.10.8 and 0.5.0. There is not much difference in terms of msg resending. And I also made a quick test on your scenario, the QoS 1/2 msg is successfully being resent when the client connects with a persistent session. So I guess you might be considering to set the "qos_duration" in "nanomq.conf" to a minimum value for a faster resending.
This value controls the resend/checker timer of each client/pipe, if you set this value to 360s, then you have to wait another 360s to get the resending function started. If this doesn't resolve your issue, please share your PAHO code/ or test it with an MQTT client tool, so that we can be guaranteed to work on the same page. |
Beta Was this translation helpful? Give feedback.
-
Thanks for this, we are looking into it. Are there any other settings that could possibly cause this issue? For reference, we are launching NanoMQ through another program and don't specify a nanomq.conf file. We will try the following: |
Beta Was this translation helpful? Give feedback.
-
We are still seeing this issue when setting the |
Beta Was this translation helpful? Give feedback.
-
@justStokes hi, if the nanomq.conf file is not specified, then it will use 10 as a default value; I expect you will also see the QoS msg is being retransmitted after 10 sec. No other config params affects the resend timer But I suspect this is sth else, I was missing this condition: perhaps I misunderstand your issue. I was talking about the condition as follows: client A publish msg to client B (MQTT 3.1.1 with clean session disabled) |
Beta Was this translation helpful? Give feedback.
-
does it means, nanomq failed to forward any msg to any client? or only the reconnected client? |
Beta Was this translation helpful? Give feedback.
-
Hello, I've also been able to reproduce this on the latest master (latest commit being: Summary:While using nanomq, if a client is kicked for exceeding its keepalive time with clean-sessions off, the client will not be aware that it has been kicked by the broker. The client will be able to continue to send messages to the broker but no messages will ever be routed back to it. This behavior is not the case with clean-sessions enabled. The same test can be performed with the
|
Beta Was this translation helpful? Give feedback.
-
Hi bro @nickschiffer, thanks for your detailed report. If the issue experienced by @sumeetkler & @justStokes is the same issue as yours, Then I probably know what is behind this. BTW, do you guys think preserving sockets is valuable? or just close it like mosquitto does? |
Beta Was this translation helpful? Give feedback.
-
Before you guys reply me with your thoughts, I have submitted a PR to make it work as the same way of mosquito. |
Beta Was this translation helpful? Give feedback.
-
For this thought, how is the client expected to know to close the socket? When the client is kicked does nanoMQ send some indication to the client itself? |
Beta Was this translation helpful? Give feedback.
-
@JaylinYu Thank you for the quick reply and fix. I did some testing and your commit to nng seems to fix the bug we encountered. ❯ mosquitto_sub -p 1234 -t test/topic -k 10 -v -c -i test_client -q 1
test/topic test_message
^Z
[1] + 18061 suspended mosquitto_sub -p 1234 -t test/topic -k 10 -v -c -i test_client -q 1
❯ fg
[1] + 18061 continued mosquitto_sub -p 1234 -t test/topic -k 10 -v -c -i test_client -q 1
test/topic test_message <-- sent while subscriber was asleep but before kick
test/topic test_message <-- rx'd again
test/topic test_message <-- rx'd again
test/topic test_message_2 <-- sent while subscriber was asleep but after kick
test/topic test_message_3 <-- sent after subscriber was woken up and reconnected
I first tested that once kicked, the client is informed of the disconnect via the closed socket and therefore is able to reconnect and receive new messages. I also tested the scenario where messages are published while the subscriber is asleep and those are delivered once the subscriber reconnects. I sent messages while the subscriber was asleep before and after the kick. The messages sent before the kick are received a few times, but that is allowed with QOS1. FWIW I do see some internal warning logs from the broker that may or may not be interesting to you. Otherwise, it seems to behave properly after some quick testing. Warning: close pipe & kick client due to KeepAlive timeout!
2023-03-17 10:21:51 [17979] WARN /home/nschiffer/nanomq/nng/src/sp/transport/mqtt/broker_tcp.c:609 tcptran_pipe_recv_cb: nni aio recv error!! Object closed
2023-03-17 10:21:51 [17979] WARN /home/nschiffer/nanomq/nng/src/sp/transport/mqtt/broker_tcp.c:609 tcptran_pipe_recv_cb: nni aio recv error!! Object closed
2023-03-17 10:21:51 [17979] WARN /home/nschiffer/nanomq/nng/src/sp/transport/mqtt/broker_tcp.c:857 tcptran_pipe_recv_cb: tcptran_pipe_recv_cb: recv error rv: 139
2023-03-17 10:21:51 [17979] WARN /home/nschiffer/nanomq/nng/src/sp/transport/mqtt/broker_tcp.c:857 tcptran_pipe_recv_cb: tcptran_pipe_recv_cb: recv error rv: 139
|
Beta Was this translation helpful? Give feedback.
-
Glad my PR works. Yes, only QoS 1 msg will be cached when session is kept. |
Beta Was this translation helpful? Give feedback.
-
My original idea was like: never let client knows if it is still using the same socket of pre-existed connection. This is usually happens in real case in poor network situation. Networking is off for a while, both side of TCP is silence and will not send FIN to close the socket. And I think it is better to get over with it once the network back to normal (the disconnect is fired on MQTT layer). |
Beta Was this translation helpful? Give feedback.
-
I gonna close this issue and convert it to discussion |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
I recently upgraded to version
0.10.8
of NanoMQ from0.5.0
. I am using the Paho MQTT client embedded client inside my application to connect to the broker. In the connection configuration I am disabling clean sessions and sending all MQTT payloads with QOS level 1.In this configuration if the client disconnects from the broker and reconnects, the broker will stop forwarding the MQTT payloads for the subscribed topics to the client.
NOTE: from the clients perspective the connection request as well as the subscription requests were all valid upon reconnection.
Expected behavior
With clean session disabled and all payloads published using QOS 1; if a client disconnects and reconnects to the MQTT broker, the broker will forward all payloads for topics subscribed to by the client to the client. This includes any payloads that were sent while the client was disconnected as well as new payloads that were sent after the client reconnected.
Actual Behavior
The client does not receive any payloads from the broker after reconnecting.
To Reproduce
nanomq start --url nmq-tcp://127.0.0.1:1243
One note, the exact same configuration on the client side is used between using versions
0.5.0
and0.10.8
. If I revert back to 0.5.0 I do not see this behaviour and after a disconnect+reconnect the client still receives all data from the broker.** Environment Details **
0.10.8
20.04.1-Ubuntu
Clang-10
Client SDK
Paho MQTT Embedded-C Client
Additional context
Terminating NanoMQ and relaunching it resolves the issue and my application is able to receive the payloads.
Beta Was this translation helpful? Give feedback.
All reactions