NBSSLClient dies mid-xfer

I'm having issues with NBSSLClient dying right in the middle of a write and going into an infinite loop in synchronous mode.

I'm sending HTTPS POST messages which can work fine for for several minutes or hours, however, eventually the write() dies right in the middle of a 'client.println()' statement. Because the system is in synchronous mode it goes into an infinite loop polling the serial port in NBClient.ready() waiting on MODEM.ready(). The loop is caused by the line 'while (ready() == 0);' in NBClient.cpp.

I've tried the library in asynchronous mode but it seems that a lot of changes will be necessary from top to bottom to properly support asynch.

What are the causes of this loop? Is my connection being dropped by either the modem or the receiver? I'm not sure how to debug this one.

Here is the output of one of my POSTs:

Attempting cellular modem connection
Attempting to transmit device state to cloud services
AT
OK
AT+CMEE=0
OK
AT+CFUN=0
OK
AT+CPIN?
+CPIN: READY

OK
AT+CMGF=1
OK
AT+UDCONF=1,1
OK
AT+CTZU=1
OK
AT+CGDCONT=1,"IP","hologram"
OK
AT+UAUTHREQ=1,0
OK
AT+CFUN=1
OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,0

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,2

OK
AT+CEREG?
+CEREG: 0,5

OK
Connected to tower
AT+CGATT=1
OK
AT+CGACT?
+CGACT: 1,1

OK
Connected to internet
AT+USOCR=6
+USOCR: 0

OK
AT+USOSEC=0,1,0
OK
AT+USECPRF=0,0,0
OK
AT+USOCO=0,"api.xxxxxxxxxxx.com",443
OK
Connected
Sending device state
AT+USOWR=0,5,"504F535420"
+USOWR: 0,5

OK
AT+USOWR=0,47,"2F6170706C69636174696F6E732F3564643832653231393238353638303030376561393733382F646576696365732F"
+USOWR: 0,47

OK
AT+USOWR=0,24,"356535353837646239326631356630303037353230313461"
+USOWR: 0,24

OK
AT+USOWR=0,6,"2F7374617465"
+USOWR: 0,6

OK
AT+USOWR=0,9,"20485454502F312E31"
+USOWR: 0,9

OK
AT+USOWR=0,2,"0D0A"
+USOWR: 0,2

OK
AT+USOWR=0,30,"436F6E74656E742D547970653A206170706C69636174696F6E2F6A736F6E"
+USOWR: 0,30

OK
AT+USOWR=0,2,"0D0A"
+USOWR: 0,2

OK
AT+USOWR=0,17,"436F6E6E656374696F6E3A20636C6F7365"
+USOWR: 0,17

OK
AT+USOWR=0,2,"0D0A"
+USOWR: 0,2

OK
AT+USOWR=0,22,"417574686F72697A6174696F6E3A2042656172657220"
+USOWR: 0,22

OK
AT+USOWR=0,256,"65794A68624763694F694A49557A49314E694973496E523563434936496B705856434A392E65794A7A645749694F6949315A544D355A44686C4D6D45304F54426B4D4441774D445A695A6A41325A5751694C434A7A64574A306558426C496A6F6959584270564739725A5734694C434A7A593239775A53493657794A6B5A585A705932557559323974625746755A464E30636D566862534973496D526C646D6C6A5A53356B5A574A315A794973496D526C646D6C6A5A53356B5A57786C644755694C434A6B5A585A70593255755A58687762334A30496977695A47563261574E6C4C6D646C64434973496D526C646D6C6A5A53356E5A58524462323174595735"
+USOWR: 0,256

OK
AT+USOWR=0,256,"6B496977695A47563261574E6C4C6D646C64454E766258427663326C305A564E305958526C496977695A47563261574E6C4C6D646C644578765A30567564484A705A584D694C434A6B5A585A70593255755A32563055335268644755694C434A6B5A585A705932557563474630593267694C434A6B5A585A7059325575636D567462335A6C5247463059534973496D526C646D6C6A5A53357A5A57356B51323974625746755A434973496D526C646D6C6A5A53357A5A57356B55335268644755694C434A6B5A585A70593255756332563051323975626D566A64476C76626C4E305958523163794973496D526C646D6C6A5A53357A644746305A564E30636D56"
+USOWR: 0,256

OK
AT+USOWR=0,111,"6862534A644C434A70595851694F6A45314F4441344E446B7A4E7A6773496D6C7A63794936496D46776153356E5A58527A64484A31593352

And there it hangs forever.

Thanks for any ideas.

It sounds like a timeout is needed on the USOWR. I stopped using the arduino library, but I remember experimenting with:

client.setTimeout(30000);
gprs.setTimeout(30000);
nbAccess.setTimeout(30000);

It also might be helpful to turn on timestamps on your terminal.

I'll experiment with those timeouts, I was unaware of them.

What library did you choose, or did you write your own?

Yeah I decided to talk to the modem directly. I have a topic in this forum about it.

I found the Arduino library very hard to follow/edit. It is broken up into soo many pieces and seems like it was just just modified from the gsm library. Also, it is not handling the power and reset pins correctly in my opinion.

@zbelding

Got a new version of the SARA firmware: SARA-R410M-02B-01-L0.0.00.00.05.08_A.02.04_IP.zip. Seems to have resolved my problems after some days of running it.

jfarque:
@zbelding

Got a new version of the SARA firmware: SARA-R410M-02B-01-L0.0.00.00.05.08_A.02.04_IP.zip. Seems to have resolved my problems after some days of running it.

EDIT - I left the board for a few hours and the modem started working again and was upgraded!

@jfarque - I'm having similar issues. where did you get the upgrade file and what was your method to upgrade. I just bricked my modem using extraPutty and below files. It looked to be going OK but then wouldn't comunicate at all after installing stg 2.

Package set #0, it will update >99% of the units
Use this set first
0bb_stg1_pkg1_0m_L56A0201_to_L58A0204.bin
0bb_stg1_pkg2_4m_L56A0201_to_L58A0204.bin
0bb_stg1_pkg3_8m_L56A0201_to_L58A0204.bin
0bb_stg2_L56A0201_to_L58A0204.bin

jfarque:
@zbelding

Got a new version of the SARA firmware: SARA-R410M-02B-01-L0.0.00.00.05.08_A.02.04_IP.zip. Seems to have resolved my problems after some days of running it.

How did you update the firmware? Did you have to solder a USB cable to the board and install a bridge or do you have a better way?