I am trying to get the HTTPClient library to work and I can’t figure out how to send this HTTP request to the server.
I have checked with Wireshark on the receiving side and I can see a different set of packets when HTTPClient tries to send the request. This is the request I can send from my browser and it works.
HttpClient> Connecting to IP: 192.168.1.125:8050
HttpClient> Start of HTTP Request.
GET /JSON?request=controldevicebyvalue&ref=37&value=1 HTTP/1.0
Connection: close
Accept: */*
Content-Type: text/html
HttpClient> End of HTTP Request.
HttpClient> Error: Timeout while reading response.
HttpClient> End of HTTP Response (5058ms).
HttpClient> Status Code:
HttpClient> Error: Can't find HTTP response body.
Status = -1
Body =
What am I missing as the server never acts upon this or sends back a reply?
I’ve noticed that with the HTTPClient library all of the data sent to the server is split up into smaller packets. All the data is in the right format though and the server is responding to the connect but it somehow does not either like what it sees or I am missing something in the packet headers etc. I can see it closing the connection on completion.
With the browser method I can see 1 single packet with all the data and then I see a reply from the server, then it handles the close.
I am wondering if the break up is an issue but I was on the understanding that TCP/IP handles this for you. Maybe not in the case of my server? (Homeseer 3)
Below is what wireshark shows for the browser packet.
@v8dave, if you search I believe there is a “faster” HTTPClient library that uses buffered Client.write() calls to write whole packets instead of using Client.print().
Thanks @peekay123 I’ll have a look but I finally gave up on the library and rolled my own where I build up the packet first and then transmit it. That now works. I will however have a look for the faster library and see if it works too.