Socket issues
Posted: Mon Aug 07, 2017 3:25 pm
Hi,
Firstly, let me state that this question is about establishing connections on the TCP/IP-level, me mentioning higher level stuff is to describe how I see the issue.
I'm experiencing intermittent issues with connecting to my MQTT broker (mosquitto) from my ESP32 while at the same time I am able to connect to an instance of netcat on another machine (both within the same subnet). Sometimes, if I let it retry enough times the MQTT connection succeeds after ~10 retries over a minute or so (the socket to netcat remains connected and transmitting/receives data during this time).
However, sometimes it never seems to succeed until I either
1) restart the ESP
or
2) disconnect the Wifi link to the ESP32 from within my Wifi AP (which forces re-initialization the Wifi Station and new sockets being created.)
During the time that the MQTT connection fails, I can connect with other MQTT clients to that same broker so there is no issue on that end.
Usually the connection failure messages I get are "Connection reset by peer" or "Software caused connection abort". Has anyone else experienced this kind of behavior, and did you figure out how to solve it?
I don't know if it matters, but I am initiating the connections immediately after receiving the SYSTEM_EVENT_STA_GOT_IP.
Firstly, let me state that this question is about establishing connections on the TCP/IP-level, me mentioning higher level stuff is to describe how I see the issue.
I'm experiencing intermittent issues with connecting to my MQTT broker (mosquitto) from my ESP32 while at the same time I am able to connect to an instance of netcat on another machine (both within the same subnet). Sometimes, if I let it retry enough times the MQTT connection succeeds after ~10 retries over a minute or so (the socket to netcat remains connected and transmitting/receives data during this time).
However, sometimes it never seems to succeed until I either
1) restart the ESP
or
2) disconnect the Wifi link to the ESP32 from within my Wifi AP (which forces re-initialization the Wifi Station and new sockets being created.)
During the time that the MQTT connection fails, I can connect with other MQTT clients to that same broker so there is no issue on that end.
Usually the connection failure messages I get are "Connection reset by peer" or "Software caused connection abort". Has anyone else experienced this kind of behavior, and did you figure out how to solve it?
I don't know if it matters, but I am initiating the connections immediately after receiving the SYSTEM_EVENT_STA_GOT_IP.