ConnectPort X4 - Python socket.send() returns saying it sent data but hasn't

I have a socket in python which I use to connect to a remote server over the cellular connection. However, if the cell connection drops it takes 10 min for the socket to notice - 10 minutes during which the socket still returns from socket.send() calls as if it had sent data.

AFAIK a socket should not return a byte count of sent data if it hasn’t successfully sent the data. And a blocking socket should block until it times out if it is unable to send the data.

Does digi’s modified version of the socket module modify this behavior?
Does it put the data you want to send in a buffer, assume that this data will be sent and return as if it had been sent?

Here’s the relevant part of my code :

clientsocket = socket(AF_INET, SOCK_STREAM)
clientsocket.setsockopt( SOL_SOCKET, SO_KEEPALIVE, 1)
clientsocket.setblocking(1)
clientsocket.settimeout(2.0)
clientsocket.connect((Configuration.serverAddress, Configuration.serverPort))

while ... :
	print digicli.digicli("display mobile")[1][6]
	sent = clientsocket.send(item)
	print str(int(time.clock())) + " - TCP: Data transmited. " + str(sent) + "/" + str(len(item))



I can simulate the cellular connection dropping by unplugging the cellular antenna.

Here’s what happens :


Registration Status    : 1, Registered (Home Network)
56485 - TCP: Data transmited. 75/75

Registration Status    : 1, Registered (Home Network)
56536 - TCP: Data transmited. 75/75

Registration Status    : 1, Registered (Home Network)
56545 - TCP: Data transmited. 76/76

Registration Status    : 1, Registered (Home Network)
56567 - TCP: Data transmited. 23/23

# This is where I unplugged the antenna

Registration Status    : 1, Registered (Home Network)
56596 - TCP: Data transmited. 76/76

Registration Status    : -1, Not Available
56704 - TCP: Data transmited. 23/23
56704 - TCP: Data transmited. 15/15

Registration Status    : -1, Not Available
56716 - TCP: Data transmited. 75/75

Registration Status    : -1, Not Available
56725 - TCP: Data transmited. 75/75

Notice how the socket.send call continues to return as if it had sent everything but the mobile connection has dropped?

Hi, i think your server should return a response when it gets data from your CPX4 and then you should try to read the response in your CPX4 and if its correct then data was sent correctly. If the data wasnt send correctly then you could try again.

I am not sure what your project goal is but for sending data to remote server I use a queue where I put data what i want to send to server and then I have a thread consuming this queue and trying to send an element forever until it gets correct response from the server.

And I have configured Digi Surelink to handle the mobile connection. So it reset the link or reboots the modem if necessary.

Juha