Skip to content

Commit 9b6ce75

Browse files
committed
added example for heartbeat
1 parent 68800e2 commit 9b6ce75

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

examples/esp8266/WebSocketClient/WebSocketClient.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ void setup() {
8484

8585
// try ever 5000 again if connection has failed
8686
webSocket.setReconnectInterval(5000);
87+
88+
// start heartbeat (optional)
89+
// ping server every 15000 ms
90+
// expect pong from server within 3000 ms
91+
// consider connection disconnected if pong is not received 2 times
92+
webSocket.enableHeartbeat(15000, 3000, 2);
8793

8894
}
8995

0 commit comments

Comments
 (0)