-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
HTTP response is not correct json encoded if the grpc return stream of objects. #481
Comments
Can you tell me if reverting b0be3cd fixes the problem? |
After reverting the line in the runtime/handler.go, I got response with a new line between two results like this. It is still not a valid JSON string. |
Could you describe the process you used to run the examples? Did you change any code before running make? |
I ran into this issue with my own grpc server and grpc gateway server. Then I want to find out whether the issue was caused by my own code. So I checked the example and I found the stream.proto has the same API pattern as my service. So this is what I did. I did the three go get commands mentioned in the readme go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway I run the example grpc server using command: I run the proxy using command: /usr/local/go/bin/go run /home/ling/Projects/go/src/github.com/grpc-ecosystem/grpc-gateway/examples/main.go |
I actually run make, then restarted the grpc server and the proxy. now I got empty response. (with the runtime/handler.go changes I made before. |
This is very strange. When I'm running this on my desktop I don't have this problem. Can you try running the e2e test that is in the Makefile? |
Could you tell me how to run the e2e test? |
You can use the Lines 25 to 32 in b0be3cd
|
I followed the steps, after resolved few dependency issues, the test run without any failure. for what is worth, I am using "go version go1.9 linux/amd64" and centOs7. |
So I'm rereading this now looking for additional clues. Is the bug is state dependent and only fails on the 2nd |
When there is only one record, the HTTP response payload is a good json format like this: {"result": {"uuid":"7d96031c1eaeffa392245718677778755db9c0f267b66a75"}} the moment I added more record, and there are multiple items returns via the stream gRpc API, the HTTP response payload is invalid. does not matter the record count is 2 or 3 or more, like this: |
I think this should be resolved now. Can you try it out? I'm going to preemptively close it but if you continue to have problems please reopen. |
I run the examples, then:
POST http://{{host}}:{{port}}/v1/example/a_bit_of_everything/bulk with payload {"uuid": "1234"}.
after that I run
GET http://{{host}}:{{port}}/v1/example/a_bit_of_everything the http response is {"result": {"uuid":"7d96031c1eaeffa392245718677778755db9c0f267b66a75"}}, everything is great.
then I do another POST
POST http://{{host}}:{{port}}/v1/example/a_bit_of_everything/bulk with payload {"uuid": "abcd"}.
now the GET return
{"result":{"uuid":"7d96031c1eaeffa392245718677778755db9c0f267b66a75"}}{"result":{"uuid":"7e96031c1eaeffa392245718677778755db9c0f267b66a75"}}
the response body is no longer a valid JSON string.
The text was updated successfully, but these errors were encountered: