MQTT connections

57 views
Skip to first unread message

Tarek EzzElDin

unread,
Aug 14, 2016, 10:45:23 AM8/14/16
to MQTT
Does MQTT broker server maintain open connections with the clients or it just open the connection with the client whenever there is a message to be pushed ??

Dominik Obermaier

unread,
Aug 14, 2016, 11:08:12 AM8/14/16
to mq...@googlegroups.com, Tarek EzzElDin
Hi Tarek,

the client opens a TCP connection to the broker and the connection remains open until the client disconnects. This allows the broker to push messages to the clients due to the open connection. 

The broker has no chance to open a TCP connection proactively, since this would be a huge security problem (the client would need to listen on a specific port) and would be hard to deploy due to NATs and firewalls.

You can read more about MQTT connection establishment here: http://www.hivemq.com/blog/mqtt-essentials-part-3-client-broker-connection-establishment

-Dominik

 

On 14 August 2016 at 16:45:28, Tarek EzzElDin (tarek.e...@gmail.com) wrote:

Does MQTT broker server maintain open connections with the clients or it just open the connection with the client whenever there is a message to be pushed ??
--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Tarek EzzElDin

unread,
Aug 14, 2016, 12:01:50 PM8/14/16
to MQTT
Thanks a lot for the useful information

Tarek EzzElDin

unread,
Aug 14, 2016, 12:51:26 PM8/14/16
to MQTT
Hi,
  I have another question regarding the connection establishment. Assuming we have a mobile application installed on android or iOS device. Does the application have to be running all the time in order to keep the connection opened by the client or the connection will be closed incase the application is closed or running in the background.

Actually am asking this question as we have a requirement to push notification to our mobile app users even if they aren't running the app at the moment of pushing the application.

Thanks.
Tarek EzzElDin

On Sunday, 14 August 2016 16:45:23 UTC+2, Tarek EzzElDin wrote:

Hans Jespersen

unread,
Aug 14, 2016, 3:45:33 PM8/14/16
to MQTT
The client does not have to be running all the time BUT when it's not running, it will not be connected, and it will not be able to receive messages. Messages will only be delivered once the app is running again and it re-established a connection to the broker. 

For your use case it might make sense to use the native push notification service built into the Android operating system ( see https://developer.android.com/guide/topics/ui/notifiers/notifications.html). 

You can even combine MQTT and notifications so that an Android push notification triggers the app to start and reconnect to the broker to get the remaining pending messages.

-hans
Reply all
Reply to author
Forward
0 new messages