97 Commits

Author SHA1 Message Date
Paolo Pasinetti
2432e41dcb fix(websocket): avoid long stopping time when waiting to auto-reconnect
This commit fixes an issue that occurred when auto-reconnection is enabled,
and the client is disconnected from the server. In this situation, if the
esp_websocket_client_stop() method is called, the caller could remain stuck
waiting for a maximum time equal to half of wait_timeout_ms.

This fix allows the esp_websocket_client_task to be woken up when it is
waiting to reconnect, so it can be closed promptly when requested.
2025-09-19 15:42:33 +02:00
glmfe
ce1560acb1 feat(websocket): Add websocket HTTP redirect
- Handle 301 status (moved permanently) and redirect the connection to the new host.
2025-09-02 09:52:20 -03:00
xutao
250eebf3fc feat(websocket): add separate tx lock for send and receive 2025-07-21 10:46:55 +08:00
Euripedes
e71926f6ed Merge pull request #752 from bryghtlabs-richard/feat/websocketReconnectOnClose
feat(websocket): add ability to reconnect after close (IDFGH-15455)
2025-06-27 14:31:16 +02:00
Guilherme Alves Ferreira
3863c26b79 Merge pull request #704 from bryghtlabs-richard/fix/websocketWriterLag
fix(websocket): release client-lock during WEBSOCKET_EVENT_DATA (IDFGH-14545)
2025-04-10 12:16:31 -03:00
glmfe
ce160505dc feat(websocket): add unregister event to websocket client 2025-02-12 08:46:39 -03:00
Richard Allen
030cb75ece fix(websocket): release client-lock during WEBSOCKET_EVENT_DATA
This resolves:

 1) Deadlock when trying to reserve a lock in WEBSOCKET_EVENT_DATA,
    but lock is held by a thread trying to send a websocket message.
 2) High latency caused by writers serialized with WEBSOCKET_EVENT_DATA
    while calling esp_websocket_client_send(), even when TCP window
    has enough space for the entire message being queued to send.

Multiple writers are still serialized at fragment boundaries, but
only with other writers and websocket error updates.

Fixes #625
2025-02-11 12:04:39 -06:00
Richard Allen
19891d8c3c 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.
2025-01-30 12:12:12 -06:00
Johan Stokking
42674b49f9 fix(websocket): wait for task on destroy 2025-01-29 14:30:32 +01:00
david-cermak
e069ae7762 Merge pull request #520 from johanstokking/feature/websocket/client_ds_data
feat(websocket): Support DS peripheral for mutual TLS (IDFGH-12285)
2025-01-28 16:59:34 +01:00
Johan Stokking
55385ec312 feat(websocket): Support DS peripheral for mutual TLS 2025-01-28 14:58:54 +01:00
Johan Stokking
eeeb9006eb fix(websocket): propagate error type 2025-01-25 21:52:06 +01:00
Richard Allen
beb6e57e5e chore(websocket): align structure members 2024-12-16 16:20:21 -06:00
Richard Allen
15d3a01e11 chore(websocket): remove unused client variable 2024-12-16 15:46:43 -06:00
xutao
a453ca1f38 fix(websocket): Prevent crash on network disconnect during send
When WiFi disconnects, `esp_websocket_client_task` continues polling
`esp_transport_poll_read()` with a default 1-second timeout.
If a timeout triggers `esp_websocket_client_abort_connection`,
certain resources are released.
However, if `esp_websocket_client_send_with_exact_opcode`
is still blocked at this point, it will cause a crash
when it times out and accesses the released handle.
This fix prevents potential crashes by ensuring proper
synchronization between abort and send functions.

Merges: https://github.com/espressif/esp-protocols/pull/629
2024-10-31 11:33:26 +01:00
david-cermak
72f4f7c7a3 Merge pull request #683 from bryghtlabs-richard/fix/ws-mutex-delete
fix(websocket): use proper interface to delete semaphore
2024-10-31 10:25:25 +01:00
david-cermak
a353702e04 Merge pull request #626 from euripedesrocha/websocket/fix_race_aborting_connection
Fix race condition when client set to not reconnect
2024-10-31 08:21:52 +01:00
Richard Allen
991ac40d75 fix(websocket): use proper interface to delete semaphore
On most implementations, including ESP-IDF FreeRTOS, vSemaphoreDelete()
is a macro that calls vQueueDelete(). But since the client semaphore is
created with xSemaphoreCreateRecursiveMutex(), delete it as a semaphore with vSemaphoreDelete().
2024-10-30 16:54:45 -05:00
david-cermak
bcab28c1b8 Merge pull request #633 from bryghtlabs-richard/feat/websocketBeginEnd
Feat/websocket: begin end thread events (IDFGH-13507)
2024-08-20 16:41:52 +02:00
Euripedes Rocha
0d8f2a6d53 fix(websocket): Move client to different state when disconnecting
If Websocket client is set to not reconnect, we move to Unknown state to
clean up the task after dispatching disconnected event.
2024-08-19 12:52:37 +02:00
Richard Allen
d7fa24bc20 feat(websocket): add events for begin/end thread
Add events to signal the start and end of the
websocket thread handler, only once each per client.
2024-08-16 14:45:54 -05:00
Johan Stokking
234f579bd8 feat(websocket): propagate esp_tls stack error and cert verify flags 2024-08-15 21:14:08 +02:00
Jackson Ming Hu
9d4d5d2d49 fix(websocket): don't get transport from the list if external transport is used 2024-07-16 16:53:40 +10:00
Suren Gabrielyan
906e447193 Merge pull request #573 from huming2207/feature/ws-transport-handle
feat(websocket): allow using external TCP transport handle (IDFGH-12825)
2024-07-12 16:50:33 +04:00
Suren Gabrielyan
15ae280bbe Merge pull request #608 from johanstokking/feature/websocket/tls_keepalive_ifname
feat(websocket): adding support for `if_name` when using WSS transport
2024-07-10 12:37:27 +04:00
Suren Gabrielyan
e6f9fe2385 Merge pull request #583 from DCSBL/ws-client-common-name
feat(websocket_client): Add option to set and use cert_common_name in Websocket client (IDFGH-12926)
2024-07-10 12:29:52 +04:00
Duco Sebel
3a6720ded6 feat(websocket): Add option to set and use cert_common_name in Websocket client 2024-07-10 09:19:48 +02:00
Johan Stokking
333a68936a feat(websocket): adding support for if_name when using WSS transport 2024-07-05 13:34:03 +02:00
Erki Aring
bd9f062709 feat(websocket): allow updating reconnect timeout for retry backoffs 2024-07-02 21:07:50 +03:00
Jackson Ming Hu
83ea2876fc feat(websocket): allow using external tcp transport handle 2024-06-21 14:47:03 +10:00
Suren Gabrielyan
6393fcd79a fix(websocket): Fix locking issues of esp_websocket_client_send_with_exact_opcode API
Extended examples to cover more cases
Added new config CONFIG_ESP_WS_CLIENT_ENABLE_DYNAMIC_BUFFER for testing
2024-05-17 12:37:10 +04:00
Suren Gabrielyan
c728eae5ea feat(websocket): adding support for keep_alive_enable when using WSS transport 2024-04-22 10:57:36 +04:00
Johan Stokking
5b467cbf5c fix(websocket): Skip warn on zero timeout and auto reconnect is disabled 2024-03-06 22:20:48 +01:00
David Cermak
9c54b72e1f fix(websocket): Fixed to use int return value in Tx functions 2024-02-28 12:48:06 +01:00
David Cermak
16174470ee fix(websocket): Fixed Tx functions with DYNAMIC_BUFFER 2024-02-28 12:47:59 +01:00
Eldar Hauge Torkelsen
d85311880d fix(websocket): Close websocket and dispatch event if server does not close within a reasonable amount of time. 2024-01-29 08:01:39 +01:00
Eldar Hauge Torkelsen
2b092e0db4 fix(websocket): Continue waiting for TCP connection to be closed
Prevents an issue where WEBSOCKET_EVENT_CLOSED is not sent after
websocket is closed.
2024-01-23 14:58:27 +01:00
774d1c75e6 fix: continuation after FIN in websocket client (#460) 2023-12-19 17:00:17 +01:00
Suren Gabrielyan
f523b4dc84 fix(websocket): consider failure if return value of esp_websocket_client_send_with_exact_opcode less than 0 2023-11-28 16:40:10 +04:00
Suren Gabrielyan
ba33588008 fix(websocket): fix of return value for esp_websocket_client_send_with_opcode API 2023-11-28 12:37:31 +04:00
Sojan James
ac8f1de187 fix(websocket): Return status code correctly on esp_websocket_client_send_with_opcode 2023-10-24 17:23:57 +04:00
Suren Gabrielyan
39e972544f feat(websocket): Added new API esp_websocket_client_append_header 2023-10-16 12:27:29 +04:00
Suren Gabrielyan
fae80e2f3f feat(websocket): Added new APIs to support fragmented messages transmission
Intoduced new APIs`esp_websocket_client_send_text_partial`,
            `esp_websocket_client_send_bin_partial`
            `esp_websocket_client_send_cont_mgs`
            `esp_websocket_client_send_fin`
            `esp_websocket_client_send_with_exact_opcode`
2023-10-03 18:43:58 +04:00
Suren Gabrielyan
a22391ae2c feat(websocket): Added linux port for websocket 2023-07-18 14:18:39 +04:00
Suren Gabrielyan
b5177cb23a fix(websocket): esp_websocket_client client allow sending 0 byte packets 2023-06-01 15:32:18 +04:00
David Cermak
e085826dbb fix(websocket): Cleaned up printf/format warnings (-Wno-format) 2023-05-17 07:35:21 +02:00
David Cermak
c974c14220 fix(websocket): Added unit tests to CI + minor fix to pass it 2023-05-17 07:14:48 +02:00
8bb207e9bb Fix weird error message spacings 2023-03-23 11:44:51 +01:00
Steinbart Andreas (HAU-EDS)
d047ff569c esp_websocket_client:
* Error handling improved to show status code from server
* Added new API `esp_websocket_client_set_headers`
* Dispatches 'WEBSOCKET_EVENT_BEFORE_CONNECT' event before tcp connection
2023-02-22 11:41:33 +04:00
AndriiFilippov
c6db3ea84c unite all tags under common structure
py test: update tags under common structure
2023-02-17 14:27:34 +01:00