kitex
kitex copied to clipboard
i/o timeout when no request is sent after some time
Describe the bug When no request is sent to the RPC server for some time, an "i/o timeout" error will occur.
To Reproduce Steps to reproduce the behavior:
- Go to kitex-examples/hello
- Change the time in
client/main.go
to 10 seconds.
for {
req := &api.Request{Message: "my request"}
resp, err := client.Echo(context.Background(), req)
if err != nil {
log.Fatal(err)
}
log.Println(resp)
time. Sleep(time.Second * 10) // change to 10 seconds
addReq := &api.AddRequest{First: 512, Second: 512}
addResp, err := client.Add(context.Background(), addReq)
if err != nil {
log.Fatal(err)
}
log.Println(addResp)
time. Sleep(time.Second * 10) // change to 10 seconds
}
- See error
Expected behavior
The Kitex client may not continuously be sending requests to the Kitex server.
I noticed that we can set WithReadWriteTimeout
option to temporarily solve the issue, but the documentation states
WithReadWriteTimeout sets the read/write timeout on network. IMPORTANT: this option is not stable, and will be changed or removed in the future!!! We don't promise compatibility for this option in future versions!!!
Is there some other way to prevent this particular error from occurring?
Screenshots
Kitex version: v0.5.2