feat(websocket): add ability to reconnect after close

Needed to support protocols like Socket.IO, where some
websocket closes issued by the server are reconnectable.
This commit is contained in:
Richard Allen
2025-01-30 12:06:11 -06:00
parent 85a8dac42d
commit 19891d8c3c
2 changed files with 21 additions and 6 deletions

View File

@ -48,7 +48,8 @@ typedef enum {
WEBSOCKET_ERROR_TYPE_NONE = 0,
WEBSOCKET_ERROR_TYPE_TCP_TRANSPORT,
WEBSOCKET_ERROR_TYPE_PONG_TIMEOUT,
WEBSOCKET_ERROR_TYPE_HANDSHAKE
WEBSOCKET_ERROR_TYPE_HANDSHAKE,
WEBSOCKET_ERROR_TYPE_SERVER_CLOSE
} esp_websocket_error_type_t;
/**
@ -101,6 +102,7 @@ typedef struct {
const char *password; /*!< Using for Http authentication */
const char *path; /*!< HTTP Path, if not set, default is `/` */
bool disable_auto_reconnect; /*!< Disable the automatic reconnect function when disconnected */
bool enable_close_reconnect; /*!< Enable reconnect after server close */
void *user_context; /*!< HTTP user data context */
int task_prio; /*!< Websocket task priority */
const char *task_name; /*!< Websocket task name */