Xinyuan-LilyGO / T-A7608X

MIT License
21 stars 5 forks source link

Https connection example doesn't work #17

Open GabrielZre opened 11 months ago

GabrielZre commented 11 months ago

I'm using the HttpsClient example authored by @Sukaibin11 . Board A7608E-H with latest firmware B08. I think that http.connectionKeepAlive(); // Currently, this is needed for HTTPS Doesn't really provide https connection - so as not to confuse - this setting is necessary for the proper operation of https, but it is not sufficient to establish an https connection. For now, I use an external library with an appropriate certificate.

Response:

400 The plain HTTP request was sent to HTTPS port

400 Bad Request

The plain HTTP request was sent to HTTPS port

nginx/1.10.3 (Ubuntu)

It'd be great if we could have such feature.

Additionally - I am posting data to the server in a loop, with connectionKeepAlive, when i want to close the connection with http.stop, and then run http.connect(SERVER, SSL_PORT) again - in next iteration, I get an exception:

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

Core 1 register dump: PC : 0x400d5659 PS : 0x00060e30 A0 : 0x800d525e A1 : 0x3ffb20e0
A2 : 0x3ffb9d0c A3 : 0x3f4007e5 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00ff0000 A7 : 0xff000000 A8 : 0x800d5cd4 A9 : 0x3ffb20c0
A10 : 0x00000000 A11 : 0x3f40340d A12 : 0x00000002 A13 : 0xffffffff
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x400864c1 LEND : 0x400864d1 LCOUNT : 0xfffffffd

Backtrace: 0x400d5656:0x3ffb20e0 0x400d525b:0x3ffb2100 0x400d4cd4:0x3ffb2120 0x400d27f6:0x3ffb2140 0x400d40a9:0x3ffb21b0 0x400d41d0:0x3ffb2270 0x400d6df9:0x3ffb2290

Decoded:

PC: 0x400d5651: stop_ssl_socket(sslclient_context, char const, char const, char const) at C:\XXX\Arduino\libraries\SSLClient\src\ssl_client.cpp line 339 EXCVADDR: 0x00000000

Decoding stack results 0x400d564e: stop_ssl_socket(sslclient_context, char const, char const, char const) at C:\XXX\Arduino\libraries\SSLClient\src\ssl_client.cpp line 336 0x400d5253: SSLClient::stop() at C:\XXX\Arduino\libraries\SSLClient\src\SSLClient.cpp line 69 0x400d4ccc: HttpClient::stop() at C:\XXX\Arduino\libraries\ArduinoHttpClient\src\HttpClient.cpp line 47 0x400d27f6: PostToFirebase(char const, String const&, String const&, HttpClient) at D:\XXX\sketch_jun14a/sketch_jun14a.ino line 387 0x400d40a9: gps_loop() at D:\XXX\sketch_jun14a/sketch_jun14a.ino line 307 0x400d41c8: loop() at D:\XXX\sketch_jun14a/sketch_jun14a.ino line 232 0x400d6df1: loopTask(void*) at C:\XXXi\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.9\cores\esp32\main.cpp line 50

What is a proper way to close the https connection with connectionKeepAlive defined before? Should we firstly disable it somehow to prevent such exceptions? What is exactly happening?

lewisxhe commented 11 months ago

I have never used a third-party HTTPS library, and I recommend using the built-in HTTPS feature. The general situation regarding assertions is that accessing the wrong address results in an exception.

gasagna commented 11 months ago

@GabrielZre: i have a library for this board here that makes available the built-in http(s) features of the A7608.

GabrielZre commented 11 months ago

Does someone have the example of HTTPS POST request with build-in https SIMCOM commands?

The example of https usage in docs is really stripped down, It doesn't work in my case, I am trying to find out why, maybe combining http library which I configure my apn, etc. to connect to network is conflicting...

gasagna commented 11 months ago

@GabrielZre check my previous comment.

GabrielZre commented 11 months ago

@gasagna Im looking for something with AT Commands, supporting https.

gasagna commented 11 months ago

@GabrielZre Look at that repository, please. It contains the answer to your question, but you need to do some work. I wrapped all the required AT commands to support HTTP with SSL/TLS. You can use the wrappers, or just study how the AT commands are called. If you turn on the debugging, it will output all the communication with the SIMCOM module.