HTTP using Ethernet

dvrp13
Posts: 3
Joined: Thu Apr 27, 2017 8:13 am

HTTP using Ethernet

Postby dvrp13 » Mon May 15, 2017 8:06 am

Hi everyone


I am trying to send data to a MySQL database using Ethernet on the ESP32 with HTTP Post Requests.
I was able to get an IP address using the Ethernet example but I don't know how to do the HTTP POST using Ethernet.

User avatar
rudi ;-)
Posts: 1727
Joined: Fri Nov 13, 2015 3:25 pm

Re: HTTP using Ethernet

Postby rudi ;-) » Mon May 15, 2017 11:48 am

dvrp13 wrote:Hi everyone


I am trying to send data to a MySQL database using Ethernet on the ESP32 with HTTP Post Requests.
I was able to get an IP address using the Ethernet example but I don't know how to do the HTTP POST using Ethernet.

perhabs this helps
you can simple use each example ( TCP, FTP, SMP, ... and so on )
same way.

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

dvrp13
Posts: 3
Joined: Thu Apr 27, 2017 8:13 am

Re: HTTP using Ethernet

Postby dvrp13 » Tue May 16, 2017 9:16 am

Thanks!

I was able to do a http get request using parts of the http request example.
But sometimes it is stuck in the do...while just before the putchar used to print the html code.
It prints DO 1 and DO 2 but then it is stuck.

Code: Select all

do {
            ESP_LOGI(TAG, "DO 1");
            bzero(recv_buf, sizeof(recv_buf));
            ESP_LOGI(TAG, "DO 2");
            r = read(s, recv_buf, sizeof(recv_buf)-1);
            ESP_LOGI(TAG, "DO 3");
            for(int i = 0; i < r; i++) {
                putchar(recv_buf[i]);
            }
            ESP_LOGI(TAG, "DO 4");
      } while(r > 0);

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: HTTP using Ethernet

Postby kolban » Wed May 17, 2017 12:08 am

From that code fragment, you a blocking in the sockets read() call. This is a blocking call that won't return until some data has been received over the socket.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

dvrp13
Posts: 3
Joined: Thu Apr 27, 2017 8:13 am

Re: HTTP using Ethernet

Postby dvrp13 » Sat May 20, 2017 4:33 pm

Sorry for my late answer.
It looks like the network of my university college is blocking the network traffic from the ESP32.
On that network it is detected as http proxy but all proxy network is blocked.

Would it be possible to bypass this? Maybe by changing the user agent?

Who is online

Users browsing this forum: Baidu [Spider] and 79 guests