重试403 forbidden http请求?

时间:2014-11-27 03:17:54

标签: http proxy go transport

我从Go http请求收到此消息:

&{Status:403 Forbidden StatusCode:403 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Content-Type:[text/html] Content-Length:[345] Date:[Wed, 26 Nov 2014 07:46:36 GMT] Server:[lighttpd]] Body:0xc2155b4860 ContentLength:345 TransferEncoding:[] Close:true Trailer:map[] Request:0xc2160829c0 TLS:0xc21604eb00}

我发送请求:

resp, err := client.Do(req)
if resp.StatusCode > 400 {

我的代码应该只是重试初始化httpclient的请求,而不是获取此禁止消息的请求。我收到了这条消息:

goroutine 780 [IO wait, 479 minutes]:
net.(*pollDesc).Wait(0xc2082b6a00, 0x72, 0x0, 0x0)
    /usr/local/go/src/net/fd_poll_runtime.go:84 +0x47
net.(*pollDesc).WaitRead(0xc2082b6a00, 0x0, 0x0)
    /usr/local/go/src/net/fd_poll_runtime.go:89 +0x43
net.(*netFD).Read(0xc2082b69a0, 0xc2080e5000, 0x1000, 0x1000, 0x0, 0x7fd302e42fd8, 0xc20c8359a0)
    /usr/local/go/src/net/fd_unix.go:242 +0x40f
net.(*conn).Read(0xc2080c20d8, 0xc2080e5000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/go/src/net/net.go:121 +0xdc
crypto/tls.(*block).readFromUntil(0xc2081c0f60, 0x7fd302e44538, 0xc2080c20d8, 0x5, 0x0, 0x0)
    /usr/local/go/src/crypto/tls/conn.go:454 +0xe6
crypto/tls.(*Conn).readRecord(0xc2082a6840, 0x17, 0x0, 0x0)
    /usr/local/go/src/crypto/tls/conn.go:539 +0x2da
crypto/tls.(*Conn).Read(0xc2082a6840, 0xc2082e3000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/go/src/crypto/tls/conn.go:904 +0x166
net/http.noteEOFReader.Read(0x7fd302e48ee8, 0xc2082a6840, 0xc20805d238, 0xc2082e3000, 0x1000, 0x1000, 0x7612c0, 0x0, 0x0)
    /usr/local/go/src/net/http/transport.go:1270 +0x6e
net/http.(*noteEOFReader).Read(0xc2081701e0, 0xc2082e3000, 0x1000, 0x1000, 0xc208014400, 0x0, 0x0)
    <autogenerated>:125 +0xd4
bufio.(*Reader).fill(0xc2082cf620)
    /usr/local/go/src/bufio/bufio.go:97 +0x1ce
bufio.(*Reader).Peek(0xc2082cf620, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/go/src/bufio/bufio.go:132 +0xf0
net/http.(*persistConn).readLoop(0xc20805d1e0)
    /usr/local/go/src/net/http/transport.go:842 +0xa4
created by net/http.(*Transport).dialConn
    /usr/local/go/src/net/http/transport.go:660 +0xc9f

goroutine 17 [syscall, 489 minutes, locked to thread]:
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:2232 +0x1

goroutine 798 [IO wait, 479 minutes]:
net.(*pollDesc).Wait(0xc2082b6a70, 0x72, 0x0, 0x0)
    /usr/local/go/src/net/fd_poll_runtime.go:84 +0x47
net.(*pollDesc).WaitRead(0xc2082b6a70, 0x0, 0x0)
    /usr/local/go/src/net/fd_poll_runtime.go:89 +0x43
net.(*netFD).Read(0xc2082b6a10, 0xc2080e4000, 0x1000, 0x1000, 0x0, 0x7fd302e42fd8, 0xc20c8359b0)
    /usr/local/go/src/net/fd_unix.go:242 +0x40f
net.(*conn).Read(0xc2080c20b8, 0xc2080e4000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/go/src/net/net.go:121 +0xdc
crypto/tls.(*block).readFromUntil(0xc2081ef5f0, 0x7fd302e44538, 0xc2080c20b8, 0x5, 0x0, 0x0)
    /usr/local/go/src/crypto/tls/conn.go:454 +0xe6
crypto/tls.(*Conn).readRecord(0xc2082a6580, 0x17, 0x0, 0x0)
    /usr/local/go/src/crypto/tls/conn.go:539 +0x2da
crypto/tls.(*Conn).Read(0xc2082a6580, 0xc20828d000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/go/src/crypto/tls/conn.go:904 +0x166
net/http.noteEOFReader.Read(0x7fd302e48ee8, 0xc2082a6580, 0xc208248cb8, 0xc20828d000, 0x1000, 0x1000, 0x7612c0, 0x0, 0x0)
    /usr/local/go/src/net/http/transport.go:1270 +0x6e
net/http.(*noteEOFReader).Read(0xc208167300, 0xc20828d000, 0x1000, 0x1000, 0xc208014400, 0x0, 0x0)
    <autogenerated>:125 +0xd4
bufio.(*Reader).fill(0xc208132c60)
    /usr/local/go/src/bufio/bufio.go:97 +0x1ce
bufio.(*Reader).Peek(0xc208132c60, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/go/src/bufio/bufio.go:132 +0xf0
net/http.(*persistConn).readLoop(0xc208248c60)
    /usr/local/go/src/net/http/transport.go:842 +0xa4
created by net/http.(*Transport).dialConn
    /usr/local/go/src/net/http/transport.go:660 +0xc9f

goroutine 9904 [select, 57 minutes]:
net/http.(*persistConn).readLoop(0xc21629a8f0)
    /usr/local/go/src/net/http/transport.go:928 +0x9ce
created by net/http.(*Transport).dialConn
    /usr/local/go/src/net/http/transport.go:660 +0xc9f

goroutine 799 [select, 479 minutes]:
net/http.(*persistConn).writeLoop(0xc208248c60)
    /usr/local/go/src/net/http/transport.go:945 +0x41d
created by net/http.(*Transport).dialConn
    /usr/local/go/src/net/http/transport.go:661 +0xcbc

goroutine 781 [select, 479 minutes]:
net/http.(*persistConn).writeLoop(0xc20805d1e0)
    /usr/local/go/src/net/http/transport.go:945 +0x41d
created by net/http.(*Transport).dialConn
    /usr/local/go/src/net/http/transport.go:661 +0xcbc

goroutine 9905 [select, 57 minutes]:
net/http.(*persistConn).writeLoop(0xc21629a8f0)
    /usr/local/go/src/net/http/transport.go:945 +0x41d
created by net/http.(*Transport).dialConn
    /usr/local/go/src/net/http/transport.go:661 +0xcbc

goroutine 10958 [runnable]:
net/http.(*persistConn).writeLoop(0xc217483810)
    /usr/local/go/src/net/http/transport.go:945 +0x41d
created by net/http.(*Transport).dialConn
    /usr/local/go/src/net/http/transport.go:661 +0xcbc

goroutine 10957 [runnable]:
net/http.(*persistConn).readLoop(0xc217483810)
    /usr/local/go/src/net/http/transport.go:928 +0x9ce
created by net/http.(*Transport).dialConn
    /usr/local/go/src/net/http/transport.go:660 +0xc9f

这是什么意思?超时了吗?我不知道从哪里开始调试......

1 个答案:

答案 0 :(得分:1)

我遇到过这个问题。这基本上意味着您已达到打开文件的最大数量每个进程。对于Linux来说,它大约是1024.这是一个非常容易的事情,因为你可以有成千上万的例程。

请注意,您打开了许多内容的文件 -

=&GT;实际日志文件

=&GT; / dev files

=&GT; UNIX套接字

=&GT;网络套接字

=&GT;库文件/ lib / lib64

=&GT;可执行文件和其他程序等