AWS IoT Sample Disconnection Behavior

I am working with the AWS IoT sample on the nRF9160 development kit using Nrf connect 1.8.0.  I am testing the disconnection behavior by removing the sim card after connection has been established.  The system correctly generates the AWS_IOT_EVT_DISCONNECTED.  This launches the connect_work function.  I put the sim card back in after the disconnection event, but the connection seems to not correct properly.  On disconnection I get these three errors:

W: connection_poll_start failed, error: -119
aws_iot_connect ( error: -119 ), next connection retry in 10 seconds
E: Cloud MQTT input error: -128

After putting the sim card back in I get the messages:

AWS IoT event received ( event: 1 )
LTE event received ( event: 3 )
Network registration status: Connected - roaming

which made me think the connection had been reestablished, but on trying to send new messages the aws_iot_send fails with error: -128.

I'm confused since the connection seems to reestablish, but the aws_iot_send fails still.  

My questions:

1) where can i find what the codes mean: ie: event: 1 event: 3 error -128 for aws_iot_send etc

2) Do I need to add some other error catching to reestablish connection to allow aws_iot_send to succeed after a sim card is removed?

3) why can I reconnect to AWS while the send still fails?

  • Hello,

    I will have to get back to you on this next week. Note that we have entered the summer holiday period in Norway so staffing is low, some delayed response time should be expected.

    Regards,

    Elfving

  • Hello Jake,

    You can find errno.h in for instance <NCs version>/zephyr/lib/libc/minimal/include/errno.h

    Could you expand a bit on what situation you are wanting to be test for? Simply removing the SIM card is not recommended. Both the SIM card and its contacts can be damaged from this. 

    If the modem gets a SIM card error it also can take a while for the modem to accept another card (Which is a part of the 3GPP standard).

    Regards,

    Elfving

  • I wanted to test the behavior when LTE connection is lost, and how reestablishing that connection looks like, how data is handled, etc.  Someone recommended a faraday cage to test this behavior but I need to stay physically connected to the board which I wasn't able to do with the faraday cage.  I wasn't sure how else to test this LTE lost connection behavior.

  • I see. Well optimally you would use a test chamber where the device connects to a test network which can be turned off and on.

    Alternatively you can try a microwave (without turning it on of course), wrapping it in aluminum foil or taking it down in a parking garage or tunnel.

    Regards,

    Elfving

  • Thank you, I was able to setup a faraday cage and get it to disconnect in that way.  After removing it from the cage I get the connected - roaming status, but when trying to send over to AWS I get the error -128 which is socket not connected. 

    It looks like the AWS_IOT EVT_DISCONNECTED is being generated which sets the is_cloud_connected bool to false and queues the connect_work function.  This calls aws_iot_connect which returns 0 so the process seems to be working as intended.  But the socket to AWS still seems to not be reconnecting or has some issue even though aws_iot_connect is successful.

    Can the socket be reset or is there some other issue that may be allowing aws_iot_connect to succeed without reestablishing the socket correctly?

Related