Closed Moskus closed 1 year ago
It turns out, to noones surprise, that I got it wrong. The reason I couldn't get httpbin.org to work, was a spelling error. 😥
However, one problem remains: I'm trying to get to a server that has a rewrite rule for HTTP to HTTPS traffic. HTTP returns 301 and in a browser I would then get redirected automatically to the HTTPS connection. If I specify https directly, I access the page directly.
However, when I try to do the same using this wonderful library, I only get the 301 response.
HTTPACTION: 0,301,0Done
AT+HTTPHEAD
+HTTPHEAD: 199
HTTP/1.1 301 Moved Permanently
Date: Sun, 24 Sep 2023 09:40:09 GMT
Server: Apache/2.4.57
Location: https://mypage.no/input/
Content-Length: 239
Content-Type: text/html; charset=iso-8859-1
OK
AT+HTTPREAD=0,0
ERROR
Failed to read body. Code: -2
Received: 301
Header
----------
HTTP/1.1 301 Moved Permanently
Date: Sun, 24 Sep 2023 09:40:09 GMT
Server: Apache/2.4.57
Location: https://mypage.no/input/
Content-Length: 239
Content-Type: text/html; charset=iso-8859-1
Body
----------
Stopping HTTP service ... AT+HTTPTERM
It could be a misconfiguration of the web server, I'll have to look into that. But to me it looks like the client is trying http, and not https.
Hi @Moskus, thank you for using my library. I think this issue is really the fault of the built-in http client provided in the simcom module's firmware. I do not have control over it, nor I do recall redirection being mentioned in the AT command manual.
I have two thoughts. First, you might investigate this error in some other forums. The other thought is: can you not directly send your request to the https server, avoiding the redirection?
Again, the fault was mine. It turned out that "https://mypage.no/input" redirected to "https://mypage.no/input/" (notice the trailing slash). Using the latter URL worked fine.
Thank you for this wonderful library! I can finally use my A7608 modem with SSL. 💯
i get the same error here on i got this Waiting for modem ... OK Waiting for modem to register on network ... done Connecting ... connected Starting client ... error... code: -2
Hi @pierrechannel, Can you open a new issue? This will make it easier to help you. Thanks
It might be that I'm missing something.
Using the supplied test site, same as on the lilygo repo, worked fine:
However, using other SSL protected sites, like httpbin.org for testing, does not:
...gives errors:
What did expect was something like this (using cUrl):
There's a 97% chance I'm doing something wrong, but what? It could be that I'm missing a header content-type, but I can't figure out how to set that (and I tested cUrl without that header too).