Navigation Menu

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

Open
jacentsao opened this issue Sep 30, 2018 · 2 comments
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@jacentsao
Copy link

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?

yes

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 GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-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 

@agnivade
Copy link
Contributor

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 Issue is not actionable because of missing required information, which needs to be provided. label Sep 30, 2018
@jacentsao
Copy link
Author

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 https://web.zhihuiji.com/sync: read tcp 192.168.5.36:56318->118.194.40.71:443: i/o timeoutpanic: Post https://web.zhihuiji.com/sync: read tcp 192.168.5.36:56318->118.194.40.71:443: i/o timeout

But run in play.golang.org:

create request failed Post https://web.zhihuiji.com/sync: dial tcp: Protocol not availablepanic: Post https://web.zhihuiji.com/sync: 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 Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. 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
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants