Skip to content

Disconnecting almost inmediately #150

Open
@Ale-Coeto

Description

@Ale-Coeto

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) {
  
      }

  }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions