Skip to content

Cannot detect sudden remote server disconnections #3433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yashverma opened this issue Jul 19, 2017 · 0 comments
Open

Cannot detect sudden remote server disconnections #3433

yashverma opened this issue Jul 19, 2017 · 0 comments

Comments

@yashverma
Copy link

yashverma commented Jul 19, 2017

Basic Infos

Hardware

Hardware: ESP-01
Core Version: 2.1.0-rc2

Description

Problem description

Using WiFiClient class on esp-01 to connect to a java application socket on a PC.
By sketch logic it should reconnect when the socket opens again after initial disconnect.

The module can detect when the connection closes gracefully i.e when the application is terminated or socket is closed on PC, but if there is a sudden disconnection , like pulling out lan cable from PC ,then the module would not detect it as disconnection and WiFiClient::connected will keep returning true.

Settings in IDE

Module: Generic ESP8266 Module
Flash Size: 1MB
CPU Frequency: 80Mhz
Flash Mode: dio
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: ck

Sketch

boolean WifiManager::checkOrConnectToServer()
{
	if (WiFi.status() != WL_CONNECTED )
		return false;

	if (client != nullptr)
	client->available();

	if (client != nullptr && client->connected() && currentState == EConnectionState::ECS_ConnectedServerPrimary)
			return true;	

	client = std::shared_ptr<WiFiClient>(new WiFiClient());

	if (client->connect(getServerAddress().c_str(), getServerPort()))
	{
		currentState = EConnectionState::ECS_ConnectedServerPrimary;
		return true;
	}
	else
	{
		currentState = EConnectionState::ECS_ConnectedPrimary;
		return false;
	}


}

Debug Messages

messages here
@yashverma yashverma changed the title Cannot detect sudden client disconnections Cannot detect sudden remote server disconnections Jul 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant