Closed IOTeule closed 2 years ago
you're using the same "disconnected" client object after its socket have been closed. Once the socket is closed, it can't be reopened. In order to reconnect, just create a new client instance, and pass the same connection details to it.
Tried this client code for automatic reconnect, but fails. State isConnected() seems to be detected incorrectly.
while (1) {
if (client.isConnected()) {
std::cout << "Client connected successfully\n";
// send() } else { std::cout << "connect ... \n";
client.connectTo("127.0.0.1", 3000); } sleep(1); };
Would be glad to hear about your expert recommendation?