Skip to content

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

Open
@werdnum

Description

@werdnum

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions