Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp_websocket_client: filter client received PONG response (or add event...) (IDFGH-14804) #777

Open
microfoundry opened this issue Mar 7, 2025 · 0 comments
Assignees
Labels
Status: Opened Issue is new Type: Feature Request Feature Request for esp-protocols

Comments

@microfoundry
Copy link

Is your feature request related to a problem?

Currently when esp_websocket_client_recv() processes a PONG response it will be dispatched to the client event handler as a WEBSOCKET_EVENT_DATA with NULL data and zero length.

Describe the solution you'd like.

I would like to propose 3 options:

  1. Filter it out all together:
/**
* esp_websocket_client_recv()
*/
        if (client->last_opcode != WS_TRANSPORT_OPCODES_PONG) {
            esp_websocket_client_dispatch_event(client, WEBSOCKET_EVENT_DATA, client->rx_buffer, rlen);
        } else {
            ESP_LOGD(TAG, "Skipping event dispatch for PONG frame.");
        }
  1. Add a specific WEBSOCKET_EVENT_PONG to esp_websocket_event_id_t to allow it to be properly identified and handled by the client event function:
        if (client->last_opcode != WS_TRANSPORT_OPCODES_PONG) {
            esp_websocket_client_dispatch_event(client, WEBSOCKET_EVENT_DATA, client->rx_buffer, rlen);
        } else {
            esp_websocket_client_dispatch_event(client, WEBSOCKET_EVENT_PONG, client->rx_buffer, rlen);
        }
  1. Add a define/config option for user choice.

Describe alternatives you've considered.

See above

Additional context.

I chose option 1 as I have no need to process PONG responses at an app level. But someone might find value in the distinct ability to process PONGs at an application level...

@microfoundry microfoundry added the Type: Feature Request Feature Request for esp-protocols label Mar 7, 2025
@github-actions github-actions bot changed the title esp_websocket_client: filter client received PONG response (or add event...) esp_websocket_client: filter client received PONG response (or add event...) (IDFGH-14804) Mar 7, 2025
@espressif-bot espressif-bot added the Status: Opened Issue is new label Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new Type: Feature Request Feature Request for esp-protocols
Projects
None yet
Development

No branches or pull requests

3 participants