WifiServer - Connection reset

dennis650
Posts: 5
Joined: Mon Dec 19, 2016 11:52 am

WifiServer - Connection reset

Postby dennis650 » Sun Jan 01, 2017 6:36 pm

Hi,

i wanted to implement a WifiServer on the ESP32 with Arduino. I am so exited about the ESP32 and Ardunino. OneWire Sensors and switches i got already working.

But now i struggle with the WifiServer. I tried different Examples from ESP8266, but i didn't get it working.

I updated the latest Version of Arduino for ESP32 from github today.

I setup the ESP32 as AccessPoint. I can connect and send a request. The ESP32 sends the response, but then resets the connection, according to curl. So InternetBrowsers and curl are showing me errors.

Can you please have a look what I have done wrong?

Error with curl:

Code: Select all

curl http://192.168.4.1
<!DOCTYPE HTML>
<html><h1><Hello World!</h1></html>
curl: (56) Recv failure: Connection reset by peer

Here is my Sketch:

Code: Select all

#include <WiFi.h>

const char* WIFI_SSID = "ESP-Accesspoint";
const char* WIFI_PASSWORD = "geheimPasswort";
WiFiServer server(80);

void setup(void) {
	Serial.begin(115200);

	WiFi.mode(WIFI_AP);
	WiFi.softAP(WIFI_SSID, WIFI_PASSWORD);

	server.begin();
}

void loop(void) {

	// Check if a client has connected
	WiFiClient client = server.available();
	if (!client) {
		return;
	}

	// Wait until the client sends some data
	Serial.println("New client");
	delay(1);

	// Read the first line of the request
	String request = client.readStringUntil('\r');
	Serial.print("Request: ");
	Serial.println(request);

	client.flush();

	String s = "HTTP/1.1 200 OK\r\n";
	s += "Content-Type: text/html\r\n\r\n";
	s += "<!DOCTYPE HTML>\r\n";
	s += "<html><h1><Hello World!</h1></html>\r\n";

	Serial.println("Response:");
	Serial.println(s);
	client.println(s);
	client.flush();

	delay(1);
	Serial.println("Client disonnected"); //When method ends
}
Thanks in advance and Greetings
Dennis

dennis650
Posts: 5
Joined: Mon Dec 19, 2016 11:52 am

Re: WifiServer - Connection reset

Postby dennis650 » Mon Jan 09, 2017 7:18 am

Hi,

seems to be an issue: https://github.com/espressif/arduino-esp32/issues/119

Greetings
Dennis

Who is online

Users browsing this forum: No registered users and 127 guests