connectrpc / examples-go Goto Github PK
View Code? Open in Web Editor NEWAn example Go server built with Connect.
Home Page: https://demo.connectrpc.com
License: Apache License 2.0
An example Go server built with Connect.
Home Page: https://demo.connectrpc.com
License: Apache License 2.0
Hi buf
team, and thank you for the awesome work you're doing on buf cli
.
While the docs explain how to consume this RPC service using http/1
and grpc
,
there is no example for http/2
.
Would you be so kind to explain what is going wrong on the below attempt:
Based on the specification https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md of what is going through the wire. The following "should" work:
protobuf
format, I chose python in this caseimport eliza_pb2
import google.protobuf.json_format
message = {"sentence": "I feel happy."}
message_data = google.protobuf.json_format.ParseDict(message, eliza_pb2.SayRequest())
message_data = message_data.SerializeToString()
message_length = "{:08x}".format(len(message_data)).encode("utf-8")
compressed_flag = "{:02x}".format(0).encode("utf-8")
So, the grpc frame must be compressed_flag + message_length + binascii.hexlify(message_data)
and results in:
000000000f0a0d49206665656c2068617070792e
\x00\x00\x00\x00\x0f\n\rI feel happy.
curl
echo -en '000000000f0a0d49206665656c2068617070792e' | curl --verbose --http2 --header "Content-Type: application/grpc+proto" --header "TE: trailers" --data-binary @- --output - https://demo.connect.build/buf.connect.demo.eliza.v1.ElizaService/Say
* Trying 35.227.208.237:443...
* Connected to demo.connect.build (35.227.208.237) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
* CAfile: /etc/ssl/cert.pem
* CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384
* ALPN: server accepted h2
* Server certificate:
* subject: CN=demo.connect.build
* start date: Apr 24 09:24:05 2023 GMT
* expire date: Jul 23 10:17:38 2023 GMT
* subjectAltName: host "demo.connect.build" matched cert's "demo.connect.build"
* issuer: C=US; O=Google Trust Services LLC; CN=GTS CA 1D4
* SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* h2h3 [:method: POST]
* h2h3 [:path: /buf.connect.demo.eliza.v1.ElizaService/Say]
* h2h3 [:scheme: https]
* h2h3 [:authority: demo.connect.build]
* h2h3 [user-agent: curl/7.86.0]
* h2h3 [accept: */*]
* h2h3 [content-type: application/grpc]
* h2h3 [te: trailers]
* h2h3 [content-length: 40]
* Using Stream ID: 1 (easy handle 0x7fe95980fc00)
> POST /buf.connect.demo.eliza.v1.ElizaService/Say HTTP/2
> Host: demo.connect.build
> user-agent: curl/7.86.0
> accept: */*
> content-type: application/grpc
> te: trailers
> content-length: 40
>
* We are completely uploaded and fine
< HTTP/2 200
< content-type: application/grpc
< grpc-accept-encoding: gzip
< trailer: Grpc-Status
< trailer: Grpc-Message
< trailer: Grpc-Status-Details-Bin
< vary: Origin
< date: Sat, 06 May 2023 17:49:38 GMT
< server: Google Frontend
< traceparent: 00-dffacc1975cead20ae1edd176a849847-b5a4abbeec7bef40-01
< x-cloud-trace-context: dffacc1975cead20ae1edd176a849847/13088775253545185088;o=1
< via: 1.1 google
< content-length: 0
< alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
<
< grpc-message: protocol error: promised 808464432 bytes in enveloped message, got 35 bytes
< grpc-status: 3
< grpc-status-details-bin: CAMSS3Byb3RvY29sIGVycm9yOiBwcm9taXNlZCA4MDg0NjQ0MzIgYnl0ZXMgaW4gZW52ZWxvcGVkIG1lc3NhZ2UsIGdvdCAzNSBieXRlcw
* Connection #0 to host demo.connect.build left intact
The grpc service accepts the request in question < HTTP/2 200
but complains about
< grpc-message: protocol error: promised 808464432 bytes in enveloped message, got 35 bytes
< grpc-status: 3
< grpc-status-details-bin: CAMSS3Byb3RvY29sIGVycm9yOiBwcm9taXNlZCA4MDg0NjQ0MzIgYnl0ZXMgaW4gZW52ZWxvcGVkIG1lc3NhZ2UsIGdvdCAzNSBieXRlcw
Can you please advise why is this happening?
This is just a test.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.