Skip to content

WebSocketsServer closes active sockets when stat is disconnected (ESP8266WiFi) #502

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

Closed
Mitxel111 opened this issue Dec 30, 2019 · 3 comments

Comments

@Mitxel111
Copy link

The code is running in ESP8266 under Arduino ESP8266 library.

ESP8266 is working in WiFi.mode(WIFI_AP_STA). ESP is connected to both the AP network and to (an independent) Stat network. There is a WebSocketsServer working through the AP network that has 2 or 3 connected active client sockets. All this is working flawlessly.

But when the code disconnects the Stat network (WiFi.disconnect()), in which there are no sockets, the WebSocketsServer closes all connected (AP network) sockets.

Additionally, the server also closes all sockets connected through the AP network when:

  • The code tries to connect, in Station mode, to an SSID not present (WL_NO_SSID_AVAIL)

  • The code tries to connect, in Station mode, to a present SSID but using a bad pass-word (WL_CONNECT_FAILED)

@zhubinsheng
Copy link

Hello, I have a similar problem. Have you solved this problem? Thank you very much for your reply

@Mitxel111
Copy link
Author

Mitxel111 commented May 14, 2020 via email

@Links2004
Copy link
Owner

Links2004 commented May 16, 2020

the problem is that the ESP is switching channels to find a new AP when the STA disconnects.
this results in a connection lost for the clients connected to the AP of the ESP.
and when the ESP finds the WiFi for STA again it may switches channels again --> AP clients connection gone again.

may this helps to understand it:
esp8266/Arduino#119 (comment)

there is nothing on the library level that can be done.
the ESP can only be on one channel at a time.
if your WiFi you connect to in STA mode is always on the same channel, try to set the AP you create with the ESP to the same channel.

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

3 participants