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

Add User-Agent and additional headers to esp_websocket_client (IDFGH-2193) #4345

Closed
wants to merge 2 commits into from

Conversation

djunod
Copy link
Contributor

@djunod djunod commented Nov 15, 2019

esp_websocket_client add the ability to:

  • Change the User-Agent string.
  • Specify additional connection headers.

@CLAassistant
Copy link

CLAassistant commented Nov 15, 2019

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot changed the title Add User-Agent and additional headers to esp_websocket_client Add User-Agent and additional headers to esp_websocket_client (IDFGH-2193) Nov 15, 2019
@djunod
Copy link
Contributor Author

djunod commented Nov 19, 2019

@igrr can I get this reviewed & merged? Thanks

@Alvin1Zhang
Copy link
Collaborator

@djunod Thanks for the contribution and sorry for not replying earlier.

@djunod
Copy link
Contributor Author

djunod commented Jan 6, 2020

@Alvin1Zhang merge conflicts resolved.

@djunod djunod closed this Jan 6, 2020
@Alvin1Zhang
Copy link
Collaborator

@djunod Thanks for the contribution, merged as 9200250, thank you.

@eang79
Copy link

eang79 commented Mar 6, 2022

Hi guys,

Silly question - how do you specify additional headers for websockets? I know that this is not the right place to ask but nobody seems to reply in the forum.

I tried to do it like this but it doesn't work with error shown below. I printed out the errors in the backend but there isn't an authorization key in the transaction leading to this failure.

websocket_cfg.uri = CONFIG_WEBSOCKET_URI;
const char *header = "{'authorization': 'Token abcdefg'}\r\n";
websocket_cfg.headers = header;
esp_websocket_client_handle_t client = esp_websocket_client_init(&websocket_cfg);
esp_websocket_register_events(client, WEBSOCKET_EVENT_ANY, websocket_event_handler, (void *)client);
esp_websocket_client_start(client);

I (5599) WEBSOCKET: Connecting to wss://anexample.ddns.net/...
E (23899) esp-tls: Failed to connnect to host (errno 113)
E (23899) esp-tls: Failed to open new connection
E (23899) TRANS_SSL: Failed to open a new connection
E (23899) TRANSPORT_WS: Error connecting to host anexample.ddns.net:443
E (23909) WEBSOCKET_CLIENT: Error transport connect

The function esp_transport_ws_set_headers() seems useful but its unclear how to use it. Also, specifying headers using a function in a lower-level layer seem to be incorrect.

Any tips or advice greatly appreciated, thanks!
Ed

gabsuren pushed a commit to gabsuren/esp-protocols-1 that referenced this pull request Apr 8, 2022
euripedesrocha pushed a commit to euripedesrocha/esp-protocols that referenced this pull request Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants