go-zero
go-zero copied to clipboard
Api is timeout, http code is 503, but body is empty
go version: go1.16.4 go zero verison: v1.4.0
The api RestConf timeout is 12000 and sleep 15s in logic code.
Below is the logic code
`func (l *TestLogic) Test(req *types.TestReq) (resp *types.TestResp, err error) {
fmt.Println(time.Now(), "sleep 15s start")
time.Sleep(15*time.Second)
fmt.Println(time.Now(), "sleep 15s end")
return &types.TestResp{}, nil
}`
the api is response with http code 503, but body is empty
Log:
{ "@timestamp": "2022-08-08T16:29:08.214+08:00", "caller": "handler/loghandler.go:174", "content": "[HTTP] 503 - POST - /tool/v1/test 127.0.0.1:53971 - curl/7.64.1 - slowcall(slowcall(12004.2ms))", "duration": "12004.2ms", "level": "slow", "span": "f90b3389d5693474", "trace": "cd2df0de72eb6349cba3c35c935e6f32" }
curl info:
- Trying 127.0.0.1...
- TCP_NODELAY set
- Connected to 127.0.0.1 (127.0.0.1) port 1008 (#0)
POST /tool/v1/test HTTP/1.1 Host: 127.0.0.1:1008 User-Agent: curl/7.64.1 Accept: / Content-Type: application/json Content-Length: 6
- upload completely sent off: 6 out of 6 bytes
- Empty reply from server
- Connection #0 to host 127.0.0.1 left intact curl: (52) Empty reply from server
- Closing connection 0
why response body is empty???
What kind of response body do you expect?
We need request timeout in the body, how to set it? If there is nothing in body , We can't get the http code.
@kevwan
Bot detected the issue body's language is not English, translate it automatically. π―ππ»π§βπ€βπ§π«π§πΏβπ€βπ§π»π©πΎβπ€βπ¨πΏπ¬πΏ
@kevwan
fixed.