Re: [grpc-io] grpc-go: Getting raw bytes from the wire

1,438 views
Skip to first unread message

Eric Anderson

unread,
Jun 15, 2015, 12:49:17 PM6/15/15
to Samir Bhatt, grpc-io
You can use the options WithCodec as a client and CustomCodec as a server to change the marshaller. That does mean that you most likely wouldn't use the code generator, since it would be trying to use protobuf.

On Sat, Jun 13, 2015 at 12:46 AM, Samir Bhatt <sbbh...@gmail.com> wrote:
Hi,

Forgive me if this question has an obvious answer. Is there a way to dump the raw protocol buffer bytes from the wire?

Setup: I have a client written in C++ that connects to a gRPC server written in Go. I want the Go server to take the raw bytes from the wire and forward the buffer over a websocket to a javascript webapp which will use protobuf.js to decode.

I'd rather not have grpc-go unmarshal the protobuf message from the c++ client just to marshal the same data to send to the js browser app.

Side note: Can't wait for Fetch or similar to allow for a browser-based gRPC endpoint.

Thanks everyone!

Samir

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/cc533670-899b-4e42-88d3-e9503404aa97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Qi Zhao

unread,
Jun 15, 2015, 1:52:40 PM6/15/15
to Eric Anderson, Samir Bhatt, grpc-io
The simple way to achieve this is you can have a revised version of Codec.Unmarshal on server side to achieve this -- let https://github.com/grpc/grpc-go/blob/d6f8134fd2e79a0a2a40f284d5552065fb6a8e3c/rpc_util.go#L71 send your raw bytes to your webapp as Eric already pointed out.

I am not clear about your architect design. If the above approach seems hacky to you, you can abandon the code generated by protobuf code generator and have your own stuff so that you have freedom to construct the counterpart of https://github.com/grpc/grpc-go/blob/master/test/grpc_testing/test.pb.go#L544.


For more options, visit https://groups.google.com/d/optout.



--
Thanks,
-Qi
Reply all
Reply to author
Forward
0 new messages