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
  • Hi,

    We have a custom board and I'll try to collect the modem trace. These are the logs I get from MQTT - 

    [00:18:31.920,135] <dbg> aws_iot.aws_iot_send: Publishing to topic: test/things/protobuf/publish/testing/
    [00:18:31.920,135] <dbg> net_mqtt.mqtt_publish: (0x20020ff8): [CID 0x20021df8]:[State 0x06]: >> Topic size 0x00000026, Data size 0x00000039
    [00:18:31.920,257] <dbg> net_mqtt_enc.pack_utf8_str: (0x20020ff8): >> str_size:00000028 cur:0x2002919a, end:0x2002957d
    [00:18:31.920,288] <dbg> net_mqtt_enc.pack_uint16: (0x20020ff8): >> val:0026 cur:0x2002919a, end:0x2002957d
    [00:18:31.920,288] <dbg> net_mqtt_enc.mqtt_encode_fixed_header: (0x20020ff8): << msg type:0x30 length:0x00000061
    [00:18:31.920,288] <dbg> net_mqtt_enc.packet_length_encode: (0x20020ff8): >> length:0x00000061 cur:0x00000000, end:0x00000000
    [00:18:31.920,318] <dbg> net_mqtt_enc.mqtt_encode_fixed_header: (0x20020ff8): Fixed header length = 02
    [00:18:31.920,318] <dbg> net_mqtt_enc.pack_uint8: (0x20020ff8): >> val:30 cur:0x20029198, end:0x2002957d
    [00:18:31.920,318] <dbg> net_mqtt_enc.packet_length_encode: (0x20020ff8): >> length:0x00000061 cur:0x20029199, end:0x2002957d
    [00:18:31.920,349] <dbg> net_mqtt.client_write_msg: (0x20020ff8): [0x20021df8]: Transport writing message.
    [00:18:31.920,410] <dbg> net_mqtt.client_write_msg: (0x20020ff8): Transport write failed, err_code = -104, closing connection
    [00:18:31.920,410] <dbg> net_mqtt_sock_tls.mqtt_client_tls_disconnect: (0x20020ff8): Closing socket 1
    [00:18:31.920,471] <dbg> aws_iot.mqtt_evt_handler: MQTT_EVT_DISCONNECT: result = -104
    [00:18:31.932,220] <dbg> net_mqtt.mqtt_publish: (0x20020ff8): [CID 0x20021df8]:[State 0x00]: << result 0xffffff98
    

    I see that MQTT disconnects with an error code of -104 ( ECONNRESET 104 /* Connection reset by peer */). Can we figure out why the connection is being reset? Thanks!

    Nikil

Reply
  • Hi,

    We have a custom board and I'll try to collect the modem trace. These are the logs I get from MQTT - 

    [00:18:31.920,135] <dbg> aws_iot.aws_iot_send: Publishing to topic: test/things/protobuf/publish/testing/
    [00:18:31.920,135] <dbg> net_mqtt.mqtt_publish: (0x20020ff8): [CID 0x20021df8]:[State 0x06]: >> Topic size 0x00000026, Data size 0x00000039
    [00:18:31.920,257] <dbg> net_mqtt_enc.pack_utf8_str: (0x20020ff8): >> str_size:00000028 cur:0x2002919a, end:0x2002957d
    [00:18:31.920,288] <dbg> net_mqtt_enc.pack_uint16: (0x20020ff8): >> val:0026 cur:0x2002919a, end:0x2002957d
    [00:18:31.920,288] <dbg> net_mqtt_enc.mqtt_encode_fixed_header: (0x20020ff8): << msg type:0x30 length:0x00000061
    [00:18:31.920,288] <dbg> net_mqtt_enc.packet_length_encode: (0x20020ff8): >> length:0x00000061 cur:0x00000000, end:0x00000000
    [00:18:31.920,318] <dbg> net_mqtt_enc.mqtt_encode_fixed_header: (0x20020ff8): Fixed header length = 02
    [00:18:31.920,318] <dbg> net_mqtt_enc.pack_uint8: (0x20020ff8): >> val:30 cur:0x20029198, end:0x2002957d
    [00:18:31.920,318] <dbg> net_mqtt_enc.packet_length_encode: (0x20020ff8): >> length:0x00000061 cur:0x20029199, end:0x2002957d
    [00:18:31.920,349] <dbg> net_mqtt.client_write_msg: (0x20020ff8): [0x20021df8]: Transport writing message.
    [00:18:31.920,410] <dbg> net_mqtt.client_write_msg: (0x20020ff8): Transport write failed, err_code = -104, closing connection
    [00:18:31.920,410] <dbg> net_mqtt_sock_tls.mqtt_client_tls_disconnect: (0x20020ff8): Closing socket 1
    [00:18:31.920,471] <dbg> aws_iot.mqtt_evt_handler: MQTT_EVT_DISCONNECT: result = -104
    [00:18:31.932,220] <dbg> net_mqtt.mqtt_publish: (0x20020ff8): [CID 0x20021df8]:[State 0x00]: << result 0xffffff98
    

    I see that MQTT disconnects with an error code of -104 ( ECONNRESET 104 /* Connection reset by peer */). Can we figure out why the connection is being reset? Thanks!

    Nikil

Children
No Data
Related