Skip to content
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

Disconnecting almost inmediately #150

Open
Ale-Coeto opened this issue Nov 19, 2023 · 0 comments
Open

Disconnecting almost inmediately #150

Ale-Coeto opened this issue Nov 19, 2023 · 0 comments
Assignees

Comments

@Ale-Coeto
Copy link

I am using a Lolin Nodemcu and when running the code, sometimes the websocket client connects and then disconnects inmediately. When this happens I restart the nodemcu and then it works, but it is a recurrent problem. I am using the WebsocketsClient.

For now, I am using the following code, but I don't know if there is a better way to ensure it reconnects.

// Connect to server (in setup)
socketConnected = client.connect(websockets_connection_string);

//Check if it failed to connect (in loop)
 if (!socketConnected) {
    socketConnected = client.connect(websockets_connection_string);
    unsigned long ms3 = micros();

      while ((micros() - ms3) < 30) {
  
      }

  }
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

2 participants