Hi,
We have SODAQ SARA R412M Board and we are using DU NBIOT sim and established stable connection for NB-IOT. For this project we are using https://www.allthingstalk.com/ platform for sending our sample readings from sensors. The issue is after sending data for once, the socket creation is keeps on failing. Only after reset button pressed it is working fine. Below is code we used for socket creation.
void sendMessageThroughUDP()
{
DEBUG_STREAM.println();
DEBUG_STREAM.println("sending message through UDP to ATT");
//int localPort = 16666; // my addition
int localPort = 17777;
int socketID = r4x.socketCreate(localPort);
DEBUG_STREAM.println(socketID);
if (socketID >= 7 || socketID < 0) {
DEBUG_STREAM.println("failed to create socket");
DEBUG_STREAM.println("the value of failed socket id is");
DEBUG_STREAM.println(socketID);
RED();
delay(1000);
return;
}
DEBUG_STREAM.println("socket created in the device!");
And this is serial monitor output
failed to create socket
the value of failed socket id is
-1
Do you use the latest version of our library? v2.1.0
Can you check that after sending the first message you turn off the modem?
When you want to send a new message, do you check the modem is on?
Do you check you still have an ip address before sending a message?
Sometimes when you check the network if you are attached you need to wait a second more to obtain an ip address before you are able to create a new socket.
With manually closing the ports you only solve the issue probably temporary.
Can you add inside your code to close all sockets before opening a new one?
You can also turn off the modem completely to force close the sockets and restart the modem to create a new session.