Hi all
I want to send http request from AP. Is it possible?
Or http request just can send from STA?
Can I use http request in AP mode?
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: Can I use http request in AP mode?
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?
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.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.
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?
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.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: Can I use http request in AP mode?
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).
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).
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: Can I use http request in AP mode?
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?
When I use esp-idf "http_request" sample code, the result is same.
This is the log output below:
It looks like socket connect issue, but I don't know how to fix it.
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
Who is online
Users browsing this forum: atx823, Majestic-12 [Bot] and 231 guests