Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

Do not post any new messages.

MQTT broker automatically disconnects the client

With mongoose MQTT broker, when the client is connected, the broker will automatically disconnect. Later, it is found that while is used in mg_do_recv to read TCP data for many times. When the second reading occurs, lwip returns the WOULDBLOCK error, and MG_F_CLOSE_IMMEDIATELY is set in mg_recv_tcp, causing the link to disconnect. The MG_F_CLOSE_IMMEDIATELY flag should not be set after multiple reads of data, isn't it?
The code structure is as follows:
do {
n = nc->iface->vtable->tcp_recv(nc, buf, len);
if (n > 0) {
//do something
} else if (n < 0) {
} while (res > 0 && !(nc->flags & (MG_F_CLOSE_IMMEDIATELY | MG_F_UDP)));

Sign In or Register to comment.