Hi all, I’m having some issues making HTTP connections in Python (via the serial module) and I’m not sure why—I keep on getting the “5—HTTP connection error due to internal trouble” error.
I’ve had success running the following AT commands outside of Python, even though I get some errors in response:
AT+CGACT=1,3
AT+KCNXFG=3,"GPRS","nimblink.gw12.vzwentp"
AT+KHTTPCFG=3,"www.dweet.io",80
OK
+KCNX_IND: 3,4,1
+KCNX_IND: 3,1,0
+KHTTP_IND: 1,1
+KCNX_IND: 3,5, 30
+KHTTP_ERROR: 1, 5
+KHTTP_IND: 1,0
+KCNX_IND: 3,3
+KCNX_IND: 3, 0, 0
AT+KHTTPCNX=1
+KCNX_IND: 3,4,1
+KCNX_IND: 3,1,0
+KHTTP_IND: 1,1
+KCNX_IND: 3,5, 30
+KHTTP_ERROR: 1, 5
+KHTTP_IND: 1,0
AT+KHTTPGET=1,"/dweet/for/my-thing?hello=world"
CONNECT
...
+KHTTP_IND: 1, 3, 387, 200, "OK"
+KCNX_IND: 3, 5, 30
+KHTTP_ERROR: 1, 5
+KHTTP_IND: 1, 0
I’m not sure why I keep on getting the KHTTP 5
error and then the modem would indicate a successful connection afterwards. In general I’ve been able to execute AT commands through Python’s serial module, but repeating the same AT commands in Python somehow isn’t working.
import serial
s = serial.Serial("/dev/ttyUSB0", ...)
s.write('AT+CGACT=1,3\r'.encode())
s.write('AT+KCNXFG=3,"GPRS","nimblink.gw12.vzwentp"\r'.encode())
s.write('AT+KHTTPCFG=3,"www.dweet.io",80\r'.encode())
...
Usually the error happens when I try to configure the HTTP connection; the modem would try a couple of times, but I typically end up with
KHTTP_ERROR: 1,5
but it never goes anywhere beyond that.
Any help or pointers would be appreciated!