eclipse / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
8.61k stars 2.33k forks source link

A mosquitto_loop_forever function blocks in mosquitto_loop_read and fails to trigger keepalive #3066

Closed jyl1007 closed 1 week ago

jyl1007 commented 2 weeks ago

Hello: In the case of network fluctuation (between connectivity and disconnection), mosquitto will trigger the keepalive mechanism at the beginning of the connection, and return a value of 19. In the above scenario, disconnecting with disconnect returns a value of 7. Before calling disconnect, I found that my connection was not on the broker, but strangely keepalive did not serve as a warning and a backstop. Later, I added some logs to mosquitto. When the problem recurred, I could see that the mosquitto_loop_read function in mosquitto_loop_forever did not exit. I checked this function carefully. One possible blocking point is the while loop in the packet__read function, which unfortunately I haven't figured out yet. I would like to ask you about whether mosquitto read and write in mosquitto_loop_forever will be affected by the critical case in the scenario of network fluctuation, and I would like to take my most sincere greetings to you.

jyl1007 commented 2 weeks ago

I repeated the problem on the 2.0.12 version. In the 2.0.15 version, I think it was a mosquitto_loop_forever function that fixed the SSL connection problem. Later, when I updated to the 2.0.18 version, the same problem occurred, so far I only have the logs related to the 2.0.12 version.

jyl1007 commented 1 week ago

The production code does not release the function's semaphore