Skip to content

feat(websocket): allow using external TCP transport handle (IDFGH-12825) #573

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

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

huming2207
Copy link
Contributor

Hi there,

This PR was originally done last year (May 2023), but I forgot to submit it... 😅

Anyway, this PR is for adding support to let WebSocket client to take external handles, similar to my another PR for MQTT client, see:

This is very useful for scenarios where:

  1. The application requires proxies to access network (via my esp_tcp_transport_addons hack for HTTP proxy access, or a SOCK4 proxy via the transport_socks_proxy.c in tcp_transport component) ;
  2. The application somehow requires external TCP/IP stack on a modem via serial port, see this example

Currently for my company, we are using my HTTP proxy library mentioned above to achieve HTTP proxy access feature. But we are currently using my modified esp-websocket-client and we wish to merge this into mainline soon instead.

Please provide suggestion if there's any and I will modify accordingly. Thanks.

Regards,
Jackson

@CLAassistant
Copy link

CLAassistant commented May 15, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot changed the title feat(websocket_client): allow using external TCP transport handle feat(websocket_client): allow using external TCP transport handle (IDFGH-12825) May 15, 2024
@huming2207
Copy link
Contributor Author

@huming2207
Copy link
Contributor Author

Any updates on this...?

@huming2207
Copy link
Contributor Author

any updates...? @gabsuren

@gabsuren
Copy link
Contributor

@huming2207 Thank you for your contribution, and we apologize for the delayed response. We are looking into it and will update you soon.

@huming2207
Copy link
Contributor Author

@gabsuren any updates? it's been a month...

@euripedesrocha
Copy link
Collaborator

@huming2207 this is in our pipeline for evaluation as Suren mentioned.
I looked into the code changes and in the current state we'll need some changes before accepting it.
You are passing only the parent transport. We should have the actual transport that will be used since it is more flexible. Some users might want to have their own implementation of the websocket transport level and if only the parent customization is needed it is easy to compose before sending to websocket client.

Also we need you to install the pre-commit hook as explained in our contributing guide and fix the issues.

@huming2207
Copy link
Contributor Author

huming2207 commented Jun 20, 2024

Hi @gabsuren @euripedesrocha

You are passing only the parent transport. We should have the actual transport that will be used since it is more flexible.

Just to clarify, it seems like esp-mqtt did the same like I did, except it calls esp_transport_destroy() at deinit. Do you mean I should add the esp_transport_destroy()? Or something else?

Also we need you to install the pre-commit hook as explained in our contributing guide and fix the issues.

Sure, I will do that.

Regards,
Jackson

@huming2207
Copy link
Contributor Author

Also, just to be clear, this PR is solely for adding parent transport support, so that we are able to connect our stuff over a HTTP proxy provided by our partner companies. We don't need to, and better off not to touch the WS transport itself. Because that's not our use case at all.

@euripedesrocha
Copy link
Collaborator

Just to clarify, it seems like esp-mqtt did the same like I did, except it calls esp_transport_destroy() at deinit. Do you mean > I should add the esp_transport_destroy()? Or something else?

Not exactly the same way. MQTT client uses the external transport as is, not the base parent, as your proposal. In MQTT client, we don't even construct the transport_list

About the cleanup, we want to keep the transport valid as long as the client is in use and simplify user task on tracking the lifetime of the transport, but it is not what I'm suggesting here. We might even go back on that decision for mqtt client.

Also, just to be clear, this PR is solely for adding parent transport support, so that we are able to connect our stuff over a HTTP proxy provided by our partner companies. We don't need to, and better off not to touch the WS transport itself. Because that's not our use case at all.

I understand that this is your use case, and to be honest, probably the most common use case but, we need to provide the feature for the general case. And given that the workaround of constructing the websocket transport is just 1 or 2 extra lines it is better to do it that way.

@huming2207
Copy link
Contributor Author

Not exactly the same way. MQTT client uses the external transport as is, not the base parent, as your proposal. In MQTT client, we don't even construct the transport_list

About the cleanup, we want to keep the transport valid as long as the client is in use and simplify user task on tracking the lifetime of the transport, but it is not what I'm suggesting here. We might even go back on that decision for mqtt client.

Ah crap, yes I misread the code.

I will modify the code accordingly,

@huming2207 huming2207 force-pushed the feature/ws-transport-handle branch 3 times, most recently from d1e7bee to bced9ea Compare June 21, 2024 04:45
@huming2207 huming2207 changed the title feat(websocket_client): allow using external TCP transport handle (IDFGH-12825) feat(websocket): allow using external TCP transport handle (IDFGH-12825) Jun 21, 2024
@huming2207 huming2207 force-pushed the feature/ws-transport-handle branch from bced9ea to 83ea287 Compare June 21, 2024 04:47
@huming2207
Copy link
Contributor Author

Hi @gabsuren @euripedesrocha

I've committed the changes. Please re-review. Thanks.

@gabsuren gabsuren requested a review from euripedesrocha July 9, 2024 17:13
@huming2207
Copy link
Contributor Author

Thanks for the approval, but it seems like the CI is failing because of lacking heaeders in the logging library? Should I provide a workaround or wait till you fix it?

@gabsuren
Copy link
Contributor

@huming2207 the failure is unrelated to your PR. I will fix it separately. Thank you for contribution!

@gabsuren gabsuren merged commit 906e447 into espressif:master Jul 12, 2024
75 of 76 checks passed
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.

5 participants