Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: Post url: read tcp xx->xx: i/o timeout returns less than 1 seconds #27942

jacentsao opened this issue Sep 30, 2018 · 2 comments


Copy link

@jacentsao jacentsao commented Sep 30, 2018

What version of Go are you using (go version)?

$ go version
go version go1.10.3 windows/amd64

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?

$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\xx\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=G:\workspace\GO
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_CFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessag                                                                                                                                                                                               e-length=0 -fdebug-prefix-map=C:\Users\xx\AppData\Local\Temp\go-build87870614                                                                                                                                                                                               2=/tmp/go-build -gno-record-gcc-switches

What did you do?

tr = &http.Transport{
	TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	Dial:            TimeoutDialer(connectTimeout, readWriteTimeout),
client := &http.Client{Transport: tr,}
if req, err := client.Post(url, "application/json;charset=utf-8", body); err == nil {
    defer req.Body.Close()
   if result, err := ioutil.ReadAll(req.Body); err == nil {
       Post url: read tcp xx->xx: i/o timeout 
}  else {

What did you expect to see?

no error occurs

What did you see instead?

I got a timeout error just like below when launch post request it returns error less than 1 seconds

Post url: read tcp xx->xx: i/o timeout 

Copy link

@agnivade agnivade commented Sep 30, 2018

I think DialContext is a better choice for what you are trying to do.

In any case, we would need a full standalone code sample, rather than a snippet. Also, what is the url ? Is it an internal server ? How do we reproduce this issue ? Have you tried with 1.11 ?

@agnivade agnivade added the WaitingForInfo label Sep 30, 2018
Copy link

@jacentsao jacentsao commented Oct 1, 2018

@agnivade I add a sample code, but output is different with output my pc local. Here is my local output:

create request failed Post read tcp> i/o timeoutpanic: Post read tcp> i/o timeout

But run in

create request failed Post dial tcp: Protocol not availablepanic: Post dial tcp: Protocol not available

After some research i found that i got a transportReadFromServerError like below:

Because of the post method, it won't retry the request though it will be okay when i retry request the same content. Why not retry when the server returns error even it's none-idempotent requests

@ALTree ALTree changed the title Post url: read tcp xx->xx: i/o timeout returns less than 1 seconds net/http: Post url: read tcp xx->xx: i/o timeout returns less than 1 seconds Oct 1, 2018
@agnivade agnivade added NeedsInvestigation and removed WaitingForInfo labels Oct 1, 2018
@agnivade agnivade added this to the Unplanned milestone Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants