This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Socket error: POLLHUP, Connection was closed by the AWS IoT broker

Hi, 

I'm trying to periodically send sensor data to the AWS server and followed the documentation here to connect and send data to the server. I use these configurations - 

CONFIG_LTE_PSM_REQ_RPTAU="11000001" (320 hours)
CONFIG_LTE_PSM_REQ_RAT="00000001" (2 seconds)
CONFIG_MQTT_KEEPALIVE=1200 (20 min)
I have programmed the device to send data (QOS 0), poll the socket for 2 seconds and then sleeps for a specified interval of time (sleep_time). I see that if I have the sleep time anywhere between 1 to 328 seconds, the device works without any problem. If I increase the sleep time to say 358 seconds, the first message is sent properly but the second message receives a Socket error: POLLHUP, Connection was closed by the AWS IoT broker message. I've played with the CONFIG_MQTT_KEEPALIVE value but I cannot increase the data send interval above 328 seconds. Do you have any ideas how I could debug this? Thanks in advance!
Nikil
Parents
  • I debugged this further and it actually seems to be caused by a POLLHUP error. When I poll the socket after sending a message, I get a revents value of 0x11 on the file descriptor. This means that the POLLIN and POLLHUP flags were set. Since the POLLIN flag was set, I call the aws_iot_input function which finally leads to the recv function in mqtt_client_tls_read to return zero and I get disconnected from AWS.

Reply
  • I debugged this further and it actually seems to be caused by a POLLHUP error. When I poll the socket after sending a message, I get a revents value of 0x11 on the file descriptor. This means that the POLLIN and POLLHUP flags were set. Since the POLLIN flag was set, I call the aws_iot_input function which finally leads to the recv function in mqtt_client_tls_read to return zero and I get disconnected from AWS.

Children
No Data
Related