File tree Expand file tree Collapse file tree 4 files changed +28
-16
lines changed Expand file tree Collapse file tree 4 files changed +28
-16
lines changed Original file line number Diff line number Diff line change @@ -254,7 +254,11 @@ void WebSockets::handleWebsocket(WSclient_t * client) {
254
254
}
255
255
256
256
if (mask) {
257
- client->tcp .read (maskKey, 4 );
257
+ if (!readWait (client, maskKey, 4 )) {
258
+ // timeout
259
+ clientDisconnect (client, 1002 );
260
+ return ;
261
+ }
258
262
}
259
263
260
264
if (payloadLen > 0 ) {
Original file line number Diff line number Diff line change 44
44
#endif
45
45
46
46
#define WEBSOCKETS_MAX_DATA_SIZE (15 *1024 )
47
- #define WEBSOCKETS_TCP_TIMEOUT (1000 )
47
+ #define WEBSOCKETS_TCP_TIMEOUT (1500 )
48
48
49
49
typedef enum {
50
50
WSC_NOT_CONNECTED,
Original file line number Diff line number Diff line change @@ -218,13 +218,17 @@ void WebSocketsClient::clientDisconnect(WSclient_t * client) {
218
218
*/
219
219
bool WebSocketsClient::clientIsConnected (WSclient_t * client) {
220
220
221
- if (client->status != WSC_NOT_CONNECTED && client->tcp .connected ()) {
222
- return true ;
223
- }
224
-
225
- if (client->status != WSC_NOT_CONNECTED) {
226
- // cleanup
227
- clientDisconnect (&_client);
221
+ if (client->tcp .connected ()) {
222
+ if (client->status != WSC_NOT_CONNECTED) {
223
+ return true ;
224
+ }
225
+ } else {
226
+ // client lost
227
+ if (client->status != WSC_NOT_CONNECTED) {
228
+ DEBUG_WEBSOCKETS (" [WS-Client] connection lost.\n " );
229
+ // do cleanup
230
+ clientDisconnect (client);
231
+ }
228
232
}
229
233
return false ;
230
234
}
Original file line number Diff line number Diff line change @@ -302,13 +302,17 @@ void WebSocketsServer::clientDisconnect(WSclient_t * client) {
302
302
*/
303
303
bool WebSocketsServer::clientIsConnected (WSclient_t * client) {
304
304
305
- if (client->status != WSC_NOT_CONNECTED && client->tcp .connected ()) {
306
- return true ;
307
- }
308
-
309
- if (client->status != WSC_NOT_CONNECTED) {
310
- // cleanup
311
- clientDisconnect (client);
305
+ if (client->tcp .connected ()) {
306
+ if (client->status != WSC_NOT_CONNECTED) {
307
+ return true ;
308
+ }
309
+ } else {
310
+ // client lost
311
+ if (client->status != WSC_NOT_CONNECTED) {
312
+ DEBUG_WEBSOCKETS (" [WS-Server][%d] client connection lost.\n " , client->num );
313
+ // do cleanup
314
+ clientDisconnect (client);
315
+ }
312
316
}
313
317
return false ;
314
318
}
You can’t perform that action at this time.
0 commit comments