Open kbialkowski opened 8 years ago
I'm trying to connect Azure IoT Hub from ESP8266 via MQTT and I'm getting exactly same rc which is -4.
My proposal is something about SSL. In addition, I tried with cloudmqtt.com, it is working without ssl, but when I tried to connect with SSL port to cloudmqtt.com with exactly same credentials , I got rc -4,
I guess, the common point is SSL/TLS,
So following changes may help you,
add #include
Ok I've managed to connect to cloudmqtt without ssl. The same code fails when I try mosquitto broker.
@smashpl Exactly the same here. I'm trying to connect with NodeMCU v2 and v3 to mosquitto broker in a Raspberry Pi and I'm getting the same exact error.
When running MQTT broker mosquitto armhf 0.15-2 on Raspberry Pi wheezy,
to avoid timeout errors "MQTT_CONNECTION_TIMEOUT" -4 when connecting,
try setting the version in PubSubClient.h to the older version 3_1
// MQTT_VERSION : Pick the version
#define MQTT_VERSION MQTT_VERSION_3_1
<<- uncomment this line
Mosquitto 0.15-2 apparently does not support the newer version 3_1_1. This got it working for me.
Setting MQTT_VERSION to 3.1 fixed my error -4 also.
Thanks!
I also searched for hours. thanks @jtonti ! Thought my firewall is the problem.
This should be improved:
Hi anyone, I'm very much afraid I'm having exactly the same issue (see my post above). Even I'm fairly ok in doing some Linux via ssh, can anyone tell me the necessary steps to compile everything needed and install mosquitto once I changed the parameter? Thanks.
If you are using multiple "Things", you have to create different Certificates for each IoT Device... Also, when you connect the client, you have to change the name:
if (client.connect("CHANGE_THIS_IT_HAS_TO_BE_DIFFERENT_FOR_EACH_DEVICE"))
Note: Check this video for more reference about Certificates
I'm trying to run "Basic ESP8266 MQTT example" with nodemcu v3 and mosquitto broker set up on raspberry pi. Unfortunately all the time I'm getting connection state -4 "Attempting MQTT connection...failed, rc=-4 try again in 5 seconds"
According to doc, its MQTT_CONNECTION_TIMEOUT - the server didn't respond within the keep alive time
This is strange because I cant publish/subscribe using .net client with m2mqtt library. On raspberry pi I can ping nodemcu module Any ideas what should I check ?