go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

Api is timeout, http code is 503, but body is empty

Open Verystone opened this issue 2 years ago β€’ 2 comments

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???

Verystone avatar Aug 08 '22 08:08 Verystone

What kind of response body do you expect?

kevwan avatar Aug 14 '22 02:08 kevwan

We need request timeout in the body, how to set it? If there is nothing in body , We can't get the http code.

Verystone avatar Aug 14 '22 08:08 Verystone

i have the same question

response does not match code timeouthandler

chowyu12 avatar Dec 06 '22 06:12 chowyu12

@kevwan

chowyu12 avatar Dec 14 '22 01:12 chowyu12

Bot detected the issue body's language is not English, translate it automatically. πŸ‘―πŸ‘­πŸ»πŸ§‘β€πŸ€β€πŸ§‘πŸ‘«πŸ§‘πŸΏβ€πŸ€β€πŸ§‘πŸ»πŸ‘©πŸΎβ€πŸ€β€πŸ‘¨πŸΏπŸ‘¬πŸΏ


@kevwan

Issues-translate-bot avatar Dec 14 '22 01:12 Issues-translate-bot

fixed.

kevwan avatar Jan 04 '23 14:01 kevwan