-1

two nodemcu device.

device1: create webserver and hotspot.

device2: connect hotspot, request web server, response -1, body empty.

I test device 1 webserver use browser from PC, success.

Test device 2, connect same route wifi, request my PC server, success.

I don't know why only (device2 request device1) or (device1 request device2) failed.

device1:

  ESP8266WebServer server(80);
  server.on("/config", []() {
    server.send(200, "text/plain", "config");
  });
  server.begin();

device2:

  HTTPClient http;
  http.begin("http://192.168.4.1/config");
  int httpCode = http.GET();
  String payload = http.getString();
  http.end();
  Serial.printf("httpCode: %d, %s \n", httpCode, payload.c_str());
yucui xiao
  • 19
  • 6

1 Answers1

0

device2 must set

WiFi.mode(WIFI_STA);

I lost this. If you connect route, no WiFi.mode(WIFI_STA) can work.

yucui xiao
  • 19
  • 6