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

otelhttp.Transport is unable to properly handle protocol switching (e.g. for websockets) #1329

Closed
djcass44 opened this issue Oct 4, 2021 · 1 comment · Fixed by #1628
Closed
Assignees
Labels
area: instrumentation Related to an instrumentation package bug Something isn't working
Milestone

Comments

@djcass44
Copy link

djcass44 commented Oct 4, 2021

Attempting to proxy a websocket through the otelhttp.Transport returns a 502 and this message: http: proxy error: internal error: 101 switching protocols response with non-writable body.

It may also affect H2C connections (and anything that provides write access to the underlying TCP connection) as stated by the Go source.


The smallest possible fix I could think of was this: djcass44@3f58f5c which disables the wrapping of the response body if the http response code is 101

This feels like a hack, however it does work. Have you got any thoughts on an optimal implementation?

@mhahl
Copy link

mhahl commented Nov 28, 2021

Hey,

Is there any progress of fixing this issue? It's super annoying, having to work around it using @djcass44 fix.

Thanks!

@MrAlias MrAlias self-assigned this Jan 31, 2022
@MrAlias MrAlias added area: instrumentation Related to an instrumentation package bug Something isn't working labels Jan 31, 2022
MrAlias added a commit that referenced this issue Feb 10, 2022
* Make the otelhttp Transport handle protocol switching

* Remove ctx field from wrappedBody

This is an unused field.

* Add tests for the wrappedBody Write method

* Add changes to changelog

* Add full transport test for #1329

* Fix grammar in changelog entry
plantfansam referenced this issue in plantfansam/opentelemetry-go-contrib Mar 18, 2022
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
@pellared pellared added this to the untracked milestone Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: instrumentation Related to an instrumentation package bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants