Closed ldemyanenko closed 4 years ago
Not sure what you mean by 'over TLS', the mqtt_server_client supports connecting over secure sockets, see the example mqtt_server_client_secure.dart in the examples directory. The browser client supports only secure webcockets(wss).
I mean something like this
MQTT and TLS MQTT relies on the TCP transport protocol. By default, TCP connections do not use an encrypted communication. To encrypt the whole MQTT communication, many MQTT brokers (such as HiveMQ) allow use of TLS instead of plain TCP. If you use the username and password fields of the MQTT CONNECT packet for authentication and authorization mechanisms, you should strongly consider using TLS.
Port 8883 is standardized for a secured MQTT connection. The standardized name at IANA is “secure-mqtt”. Port 8883 is exclusively reserved for MQTT over TLS.
https://www.hivemq.com/blog/mqtt-security-fundamentals-tls-ssl/
I'm able to set the connection with MQTT Explorer using TLS setting. But didn't find this option in mqtt_client. I'm trying to use mqtt_client in mobile app
Yes, then you need to use the mqtt_server_client configured to use secure sockets as I said above.
Do you have an example for this case?
Yes, as I've said above ' see the example mqtt_server_client_secure.dart in the examples directory'.
Was able to connect with
secure = true
no certificate
port 8883
Was able to connect with
secure = true no certificate port 8883
@ldemyanenko I have the same problem, can you give me a demo address or code snippet? Thank you
Was able to connect with
secure = true no certificate port 8883
@ldemyanenko I have the same problem, can you give me a demo address or code snippet? Thank you
As @shamblett mentioned there is an example dart file: https://github.com/shamblett/mqtt_client/blob/master/example/mqtt_server_client_secure.dart
If you want to activate TLS without certificates, it is correct that secure
should be true
but also the onBadCertificate
should be assigned as follows as in the example:
client
..secure = true
..port = 8883
..onBadCertificate = (Object a) => true;
I didn't find a way yo use MQTT over TLS.
I'm getting error mqtt connect error: SocketException: Failed host lookup: 'mqtt://yyy.xxx.net/mqtt' (OS Error: No address associated with hostname, errno = 7)
I'm able to connect to the MQTT server through MQTT Explorer app with TLS encryption but wasn't able to connect from flutter using mqtt_client.
Please help me with this issue