You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used grapi to create a server skeleton, then implemented an API that returns a stream.
# proto file
rpc GetTopAccounts (GetTopAccountRequest) returns (stream Account) {
# implementation
for {
for _, acc := range accounts {
err = svr.Send(acc)
if err != nil {
log.Printf("error streaming %+v", err)
return nil
}
}
log.Printf("iteration %d", i)
time.Sleep(1000 * time.Millisecond)
}
When calling this API with golang gRPC client, things work fine. However, if I use curl to access the same API using HTTP, the response will stop streaming after exactly 8 seconds.
go run ./cmd/server
#open another window
curl http://localhost:3100/top/10
...
{"result":{"account_id":"123"}}
{"result":{"account_id":"123"}}
{"result":{"account_id":"123"}}
# after exactly 8 seconds
curl: (18) transfer closed with outstanding read data remaining
the server prints this in console
2019/10/09 21:41:11 iteration 19
2019/10/09 21:41:11 error streaming rpc error: code = Canceled desc = context canceled
Meanwhile, running the gRPC client calling the same API can does not exhibit this problem
go run ./cmd/client
...
streams forever
...
The text was updated successfully, but these errors were encountered:
I'm stumped by this problem, please help.
I used grapi to create a server skeleton, then implemented an API that returns a stream.
When calling this API with golang gRPC client, things work fine. However, if I use curl to access the same API using HTTP, the response will stop streaming after exactly 8 seconds.
Here is my code repo
To run it:
Meanwhile, running the gRPC client calling the same API can does not exhibit this problem
The text was updated successfully, but these errors were encountered: