3

I have a MQTT client in an internal network and an MQTT server somewhere in Cloud. How can I connect to MQTT Server without opening port in the Client network?

Aurora0001
  • 18,520
  • 13
  • 55
  • 169
toto'
  • 133
  • 3

1 Answers1

4

You don't need to open any ports to connect to an external broker on a normal NAT'd internal network (e.g. a normal domestic ADSL setup.).

As long as your network allows all outbound connections (and related replies) then it should all just work.

This is because all MQTT connections are initiated by the client and are then persistent until the client closes the connection. Messages for subscriptions just flow back down this existing connection.

If you need to explicitly allow outbound ports then the default port is 1883.

If you are on a more locked down network, e.g. a corporate network that requires you to use a proxy to reach the outside world then you have 2 choices.

  1. You need an OSI layer 5 proxy e.g. socks
  2. If you only have access to a HTTP proxy then you have to hope that your external broker and client supports MQTT over Websockets.
hardillb
  • 12,813
  • 1
  • 21
  • 34