Setup:
Arduino Mega 2560 w/ Wiznet W5500 Ethernet Sheild
Using TP-Link TL-MR6400 LTE router to connect to internet over cellular connection in Uganda.
Using an HTTP Post with the following,
client.println("POST /hook HTTP/1.1");
client.print("Host: "); client.println(server);
client.println("Accept: */*");
client.print("Content-Type: text/html;");
client.println("User-Agent: Arduino/1.0");
client.println("Connection: close");
client.print("Content-Length: ");
client.println(PostData.length());
client.println();
client.println(PostData);
where PostData is a String
and Ethernet2 is the library used.
This works just fine from the US to the same AWS server, or a https://requestbin.com/ instance.
When testing from Uganda using a Raspberry Pi and curl it works fine.
$ curl -vs -d 'ABCDEFG' -H "User-Agent: Arduino/1.0" -H "Content-Type: text/html" -H "Connection: close" http://<server here>/hook
* Trying <ip here>...
* TCP_NODELAY set
* Connected to <server here> (<ip here>) port 80 (#0)
> POST /tg HTTP/1.1
> Host: <server here>
> Accept: */*
> User-Agent: Arduino/1.0
> Content-Type: text/html
> Connection: close
> Content-Length: 7
>
* upload completely sent off: 7 out of 7 bytes
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Date: Tue, 06 Aug 2019 21:06:49 GMT
< x-pd-status: sent to primary
< X-Powered-By: Express
< Content-Length: 16
< Connection: Close
<
* Curl_http_done: called premature == 0
* Closing connection 0
{"success":true}
I even tried an HTTP GET example from the Ethernet2 library,
https://www.arduino.cc/en/Tutorial/WebClientRepeating
It worked just fine in the US but in Uganda I get,
My IP address: 192.168.1.177
connecting...
connecting...
connecting...
I increased the time between requests here to 100 seconds where it is listening for the whole time inbetween.
It seems that client.connect(server, 80)
is successful and the client.print
messages go through but the message never reaches the server so there is no response. My AWS server does not recieve the request and this is the same for the requestbin instance. This behavior is mirrored in all my Arduino tests.
I thought the ISP might be blocking but the RPi can send nearly the same message. I thought maybe a timeout somewhere but I can not find where with my tests. I thought my message was too long but I reduced the size to only 10 characters with the same results.
Trying to figure out why the Arduino HTTP request cannot reach any webhooks from Uganda and how to fix it if possible. Different ISP, slower connection, cellular connection?
Any help would be appreciated.
HTTP/1.0
instead ofHTTP/1.1
. Or maybe combining all theclient.print
s so everything is send in a single packet, instead of possibly multiple (I couldn't figure out if that is even the case).