Page 1 of 1
Can I use http request in AP mode?
Posted: Thu Jun 28, 2018 3:26 am
by jimcooper
Hi all
I want to send http request from AP. Is it possible?
Or http request just can send from STA?
Re: Can I use http request in AP mode?
Posted: Thu Jun 28, 2018 4:02 am
by ESP_Sprite
As far as the TCP/IP layer is concerned, you don't have an AP, STA or wired connection, you only have a network with a bunch of IPs. As long as you have IP connectivity (which AP and STA both should give), you should be able to do http requests.
Re: Can I use http request in AP mode?
Posted: Thu Jun 28, 2018 7:07 am
by jimcooper
ESP_Sprite wrote:As far as the TCP/IP layer is concerned, you don't have an AP, STA or wired connection, you only have a network with a bunch of IPs. As long as you have IP connectivity (which AP and STA both should give), you should be able to do http requests.
But when I want to use AP sends an http request to the STA which connect to AP and got ip, there has no response.
I use two STA(sta1 & sat2)connect to a commercial router, and send http request from sta1 to sta2, the response is correct.
Did I miss some setup in AP mode?
Re: Can I use http request in AP mode?
Posted: Thu Jun 28, 2018 8:08 am
by kolban
I am assuming that you have one ESP32 running as an access point (AP) and a second ESP32 running as a station (STA). When the AP ESP32 starts up and the STA ESP32 connects to it, then you should be able to form a TCP connection from a client application running on AP to a server application running on the STA. HTTP is merely a protocol on top of TCP. When we say that the client application running on AP doesn't get a response from the server application running on STA you are likely going to want to do some debugging. For example, listing the IP addresses of both ends, attempting to form a connection from the client to the server and looking for error codes. Logging connection requests at the server. Logging error responses at the server .... and so on. From a networking standpoint, once the STA connects to the AP, both then appear as peer IP hosts to each other.
Re: Can I use http request in AP mode?
Posted: Thu Jun 28, 2018 10:39 am
by jimcooper
If my ESP32 working on APSTA mode, and I want to send a http request.
How to decide the http request send by AP or STA?
Because my ESP32 working on APSTA mode, maybe this condition is the problem?
BTW, I use ESP32 arduino library(
https://github.com/espressif/arduino-esp32).
Re: Can I use http request in AP mode?
Posted: Fri Jun 29, 2018 11:52 am
by ESP_Sprite
It depends on the IP. If the IP is in the AP subnet, it will be sent out of the AP. If it's in the STA subnet, it will be sent out of the STA. If it's in neither, it will be sent using the default route (which I think should be the STA in most circumstances)
Re: Can I use http request in AP mode?
Posted: Mon Jul 02, 2018 3:31 am
by jimcooper
When I use esp-idf "http_request" sample code, the result is same.
This is the log output below:
Code: Select all
I (16193) simple wifi: station:d8:a0:1d:40:8e:b4 join, AID=1
I (16693) simple wifi: (1)STA MAC:d8:a0:1d:40:8e:b4 IP:192.168.4.2
I (16693) simple wifi: mesh root IP:192.168.4.2
I (16693) simple wifi: DNS lookup succeeded. IP=192.168.4.2
I (16693) simple wifi: ... allocated socket
E (34923) simple wifi: ... socket connect failed errno=113
I (39923) simple wifi: DNS lookup succeeded. IP=192.168.4.2
I (39923) simple wifi: ... allocated socket
E (57683) simple wifi: ... socket connect failed errno=113
It looks like socket connect issue, but I don't know how to fix it.