con.getreply() and con.endheaders() freezing in idigi_data.py

I’m uploading my sensor data of the CP X4 to iDigi but I’m unable to get a steady upload rate.

In my slightly modified device driver and within the function ‘__upload_data’ this function is called:

self.__send_to_idigi(xml.getvalue())

The contents of xml.getvalue are about 4000 characters.
From there it goes to idigi_data.py and within this file/function there are two calls that hose up the program for a while (about a minute or more).

First and only sometimes…
con.endheaders()
…doesn’t return right away. Usually it returns within a few seconds but sometimes it takes up to and over a minute.

Then…
errcode, errmsg, headers = con.getreply()
…doesn’t return. Sometimes it returns quickly too but more often than not it just sits there for easily a minute, sometimes 2 minutes.

My understanding is that htmllib, which the con object is of is supplied by python?

CPU is pretty low ~15% and the signal strength looks good ~ 4 bars (-82dB).

Here and there I get some error messages as well, for example this one:
exception while uploading: (116, ‘Connection timed
out’)

In the config I have secure set to FALSE but I think it was the same deal with the secure connection.

What do you think is causing this?