graphql-go / graphql

An implementation of GraphQL for Go / Golang
MIT License
9.91k stars 839 forks source link

HTTP/2.0 to apollo server end with PRI command. #467

Closed rustysys-dev closed 5 years ago

rustysys-dev commented 5 years ago

Issue:

When attempting to connect to graphql via my application, routed through istio.. I get the 503 errors from the apollo-server when under desired configuration.

Question:

How can I get HTTP/2.0 working with graphql?

503 Return: HTTP/2.0

When my Istio service is setup to connect to the container via HTTP/2.0. The apollo server is setup to provide connection information with headers in logs. The output from the graphql server is as follows:

2019/04/02 04:13:02 HTTP/2.0 PRI *
2019/04/02 04:13:02 Header:

200 Return: HTTP/1.1

When my Istio service is setup to connect to the container via HTTP/1.1, the request is successful and I can successfully connect to apollo-server.

2019/04/02 04:15:50 HTTP/1.1 GET /
2019/04/02 04:15:50 Header:
2019/04/02 04:15:50   X-Forwarded-For: [10.20.39.34]
2019/04/02 04:15:50   Content-Length: [0]
2019/04/02 04:15:50   X-B3-Traceid: [a6d8269e6d4d2f19b0fd01d5cb8b1e9a]
2019/04/02 04:15:50   X-Request-Id: [a7ca483a-5ecf-497c-bbf7-00a11b1513a8]
2019/04/02 04:15:50   X-Envoy-Internal: [true]
2019/04/02 04:15:50   X-B3-Parentspanid: [b0fd01d5cb8b1e9a]
2019/04/02 04:15:50   User-Agent: [Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0]
2019/04/02 04:15:50   Accept: [text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8]
2019/04/02 04:15:50   Accept-Encoding: [gzip, deflate, br]
2019/04/02 04:15:50   X-B3-Sampled: [0]
2019/04/02 04:15:50   Upgrade-Insecure-Requests: [1]
2019/04/02 04:15:50   Cache-Control: [max-age=0]
2019/04/02 04:15:50   X-B3-Spanid: [b8f2887a314a9063]
2019/04/02 04:15:50   X-Forwarded-Proto: [https]
2019/04/02 04:15:50   Accept-Language: [en-US,en;q=0.5]
2019/04/02 04:15:50   Te: [trailers]
2019/04/02 04:15:51 HTTP/1.1 POST /query
2019/04/02 04:15:51 Header:
2019/04/02 04:15:51   Te: [trailers]
2019/04/02 04:15:51   X-Forwarded-Proto: [https]
2019/04/02 04:15:51   Referer: [https://api.iot-sys.net/]
2019/04/02 04:15:51   Accept-Encoding: [gzip, deflate, br]
2019/04/02 04:15:51   Origin: [https://api.iot-sys.net]
2019/04/02 04:15:51   Content-Length: [1468]
2019/04/02 04:15:51   X-Forwarded-For: [10.20.39.34]
2019/04/02 04:15:51   X-Request-Id: [f2a5320b-2e5c-4a42-a8ad-a3e32ef96b9f]
2019/04/02 04:15:51   X-Envoy-Internal: [true]
2019/04/02 04:15:51   User-Agent: [Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0]
2019/04/02 04:15:51   Accept-Language: [en-US,en;q=0.5]
2019/04/02 04:15:51   X-B3-Sampled: [0]
2019/04/02 04:15:51   X-B3-Spanid: [45883a02cde91ba2]
2019/04/02 04:15:51   X-B3-Parentspanid: [856123119b7c425b]
2019/04/02 04:15:51   Accept: [*/*]
2019/04/02 04:15:51   X-Apollo-Tracing: [1]
2019/04/02 04:15:51   Content-Type: [application/json]
2019/04/02 04:15:51   X-B3-Traceid: [41e263da19995171856123119b7c425b]
rustysys-dev commented 5 years ago

Accidentally closed wrong issue.. This is still active.

Fontinalis commented 5 years ago

Hey @procyclinsur, can you clear the case and tell what is your configuration, how are you using graphql-go? At this point, it sounds more like an apollo-server issue.

rustysys-dev commented 5 years ago

@Fontinalis Thank you for the response! sorry for my late reply.

The following is our listen and serve call:

I suppose I shouldn't have said apollo-server, as we are not using that to serve graphql

graphql-go seems to be used within our handler... so, I suppose it isn't directly related to this..

You wouldn't know where I should be asking would you?

sfriedel commented 5 years ago

@procyclinsur I don't have any experience with istio but is the http2 request to your GraphQL backend using https? Because out of the box the golang http server does not support unencrypted http2.

If that is the case you can try wrapping your handler with something like https://godoc.org/golang.org/x/net/http2/h2c#NewHandler

Fontinalis commented 5 years ago

Personally I would look into the go-chi/chi router, also would check that does the request get to the graphql-go part.

Also, here is a little info about the PRI method: https://http2.github.io/http2-spec/#rfc.section.11.6 This method is never used by an actual client. This method will appear to be used when an HTTP/1.1 server or intermediary attempts to parse an HTTP/2 connection preface.

rustysys-dev commented 5 years ago

Thanks guys! I think that is what I need to move forward with this issue! Sorry for posting to the wrong repo!