Skip to content
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

How Broker can send a message back to a publisher ? #15

Closed
Fbo06 opened this issue Jul 14, 2018 · 4 comments
Closed

How Broker can send a message back to a publisher ? #15

Fbo06 opened this issue Jul 14, 2018 · 4 comments

Comments

@Fbo06
Copy link

Fbo06 commented Jul 14, 2018

Hello, thirst thank you for sharing this code who is very useful. I have a question, how the broker could response to the publisher (who isn't on the local network ) because i don't see any reference to the "client".
for example a mosquito "client" send this
mosquitto_pub -m "Relay ON" -t "/MyMQTT_Sub" -h "192.168.1.96"
The broker well receive the message
and now i want to send back (from the broker) a acknowledge message like "OK the Relay is switch ON".
thank you for your response

@martin-ger
Copy link
Owner

The broker can also publish a message with a topic and if the client has subscribed for that topic, it will receive it. In MQTT there is no concept of a direct reply, but it is all done via pub/sub on topics,

If you look into the sample code: in line 86 there is a publish of the broker. If your client subscribes with:
mosquitto_sub -d -t "/MyBroker/count" -h "192.168.1.96"
it will receive these messages.

@Fbo06
Copy link
Author

Fbo06 commented Jul 15, 2018

Thank you Martin-ger, i understand the concept of pub/sub on topics but why we can't use the "Client" object ?

@martin-ger
Copy link
Owner

The client object uses a TCP/IP link to the broker. As this broker is on the local ESP, the standard TCP/IP stack doesn't allow for a loopback connection. I build a lwip-version that can support this, but it requires much more ressources than simply using the direct local pub and sub calls.

Hope, this explains.

@Fbo06
Copy link
Author

Fbo06 commented Jul 16, 2018

Another time thank you for your support.

@Fbo06 Fbo06 closed this as completed Jul 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants