-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Bug: MQTT client can receive the broker message but cannot send its own message to broker #1189
Comments
Sorry, you're going to have to provide some more details here. Which client are you using? Do you consider there is a problem with the client or the broker? Mosquitto only uses a single socket per client, your last statement is incorrect. |
@ralight Thanks for your reply. Detail of problem
Source codeYou can find that the mosquitto use different socket for receiving and sending. type define: mosquitto/lib/mosquitto_internal.h Line 159 in 2d360fd
Create two sockets when connecting to the broker: Line 60 in 2d360fd
QuestionIf the client receives the broker's heartbeat, it will assume that it is not disconnected from the broker? |
The socketpair you're talking about above is used as a control mechanism. libmosquitto's i/o thread spends most of its time blocked on a select(). When some other thread wants the select to end, the other thread writes a byte to mosq->sockpairW. This makes mosq->sockpairR readable, and so the select() returns. Note that this code is used in the mosquitto client library, but not in mosquitto itself. A single socket is used to communicate with the client. (mosq->sock). I guess if the client can receive a message from the broker, that socket must be valid. You might want to look at what's actually going on on the network using tcpdump or wireshark, or something in between. |
@ptjm Thanks you for your reply. Best Regards, |
Could you provide some example code that demonstrates the problem? The pingreq/pingresp heartbeat is handled by the client library as long as you are correctly using one of the If you mean a different heartbeat, then it is an application level heartbeat that is not part of libmosquitto. |
I'm closing this because as it stands I can't do anything about it, and don't believe the problem is in this project. If you still have a problem, please reopen and provide more information. |
Problem description:
MQTT client can receive the heartbeat from broker but cannot send its own message to broker
Influence:
Because MQTT client can receive heartbeat from broker, the client does not consider itself disconnected from the broker. So the client does not attempt to reconnect to the broker, broker will never receive any message from client.
suggestion:
I found that mosquitto use different socket for receiving and sending, that is why this problem arises.
The text was updated successfully, but these errors were encountered: