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

"Connection reset by peer" when sending PATCH request over HTTP if GRPC & Gateway are on same addr #301

Open
werdnum opened this issue Oct 25, 2021 · 0 comments · May be fixed by #302
Open

Comments

@werdnum
Copy link

werdnum commented Oct 25, 2021

When I have an endpoint that uses the PATCH method, I can't send HTTP requests to that endpoint

$ curl -vvv -X PATCH http://127.0.0.1:3001/api/tasks/4 -d '{...}'
*   Trying 127.0.0.1:3001...
* Connected to 127.0.0.1 (127.0.0.1) port 3001 (#0)
> PATCH /api/tasks/4 HTTP/1.1
> Host: 127.0.0.1:3001
> User-Agent: curl/7.79.1
> Accept: */*
> Content-Length: 72
> Content-Type: application/x-www-form-urlencoded
>
* Recv failure: Connection reset by peer
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer

Other HTTP methods work fine.

This appears to be because grapiserver uses cmux to multiplex GRPC and HTTP on the same address:

return s.mux.Match(cmux.HTTP2(), cmux.HTTP1Fast())

... and uses cmux's HTTP1Fast() matcher, which does not recognize the PATCH method:

https://github.com/soheilhy/cmux/blob/v0.1.5/matchers.go#L46-L64

With employer approval, I'll send a pull request to pass "PATCH" to the call to HTTP1Fast() in grapiserver/cmux.go.

Workaround: when I use a different addr for GRPC and HTTP, everything works fine.

werdnum added a commit to werdnum/grapi that referenced this issue Oct 25, 2021
This is a common REST method, and without this change, it's impossible to send the "PATCH" method over HTTP in configurations where the HTTP Gateway and the GRPC Gateway (e.g., the default configuration).

Resolves izumin5210#301.
@werdnum werdnum linked a pull request Oct 25, 2021 that will close this issue
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 a pull request may close this issue.

1 participant