mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-07-16 16:52:05 +02:00
header response timeout added
This commit is contained in:
@ -85,6 +85,7 @@ void WebSocketsClient::begin(const char * host, uint16_t port, const char * url,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
_lastConnectionFail = 0;
|
_lastConnectionFail = 0;
|
||||||
|
_lastHeaderSent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSocketsClient::begin(String host, uint16_t port, String url, String protocol) {
|
void WebSocketsClient::begin(String host, uint16_t port, String url, String protocol) {
|
||||||
@ -490,6 +491,12 @@ bool WebSocketsClient::clientIsConnected(WSclient_t * client) {
|
|||||||
* Handel incomming data from Client
|
* Handel incomming data from Client
|
||||||
*/
|
*/
|
||||||
void WebSocketsClient::handleClientData(void) {
|
void WebSocketsClient::handleClientData(void) {
|
||||||
|
if(_client.status == WSC_HEADER && _lastHeaderSent + WEBSOCKETS_TCP_TIMEOUT < millis()) {
|
||||||
|
DEBUG_WEBSOCKETS("[WS-Client][handleClientData] header response timeout.. disconnecting!\n");
|
||||||
|
clientDisconnect(&_client);
|
||||||
|
WEBSOCKETS_YIELD();
|
||||||
|
return;
|
||||||
|
}
|
||||||
int len = _client.tcp->available();
|
int len = _client.tcp->available();
|
||||||
if(len > 0) {
|
if(len > 0) {
|
||||||
switch(_client.status) {
|
switch(_client.status) {
|
||||||
@ -598,6 +605,7 @@ void WebSocketsClient::sendHeader(WSclient_t * client) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
DEBUG_WEBSOCKETS("[WS-Client][sendHeader] sending header... Done (%luus).\n", (micros() - start));
|
DEBUG_WEBSOCKETS("[WS-Client][sendHeader] sending header... Done (%luus).\n", (micros() - start));
|
||||||
|
_lastHeaderSent = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,6 +107,7 @@ class WebSocketsClient : protected WebSockets {
|
|||||||
|
|
||||||
unsigned long _lastConnectionFail;
|
unsigned long _lastConnectionFail;
|
||||||
unsigned long _reconnectInterval;
|
unsigned long _reconnectInterval;
|
||||||
|
unsigned long _lastHeaderSent;
|
||||||
|
|
||||||
void messageReceived(WSclient_t * client, WSopcode_t opcode, uint8_t * payload, size_t length, bool fin);
|
void messageReceived(WSclient_t * client, WSopcode_t opcode, uint8_t * payload, size_t length, bool fin);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user