requests icon indicating copy to clipboard operation
requests copied to clipboard

s5代理可能永久卡住

Open aj3423 opened this issue 2 years ago • 0 comments

当s5代理不稳定时候,有概率永久卡住不返回,原因是 rt.dialTLS(context.Background(), ... ),下面代码是我临时写死了60秒对付了下,应该怎么修复? 谢谢。

func (rt *roundTripper) getTransport(req *http.Request, addr string) error {
	// ...
	ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
	defer cancel()

	_, err := rt.dialTLS(ctx, "tcp", addr)
	// ...

卡住时候的 call 堆栈:

#	0x46c4c4	internal/poll.runtime_pollWait+0x84						/opt/go/src/runtime/netpoll.go:343
#	0x4dbe46	internal/poll.(*pollDesc).wait+0x26						/opt/go/src/internal/poll/fd_poll_runtime.go:84
#	0x4dd139	internal/poll.(*pollDesc).waitRead+0x279					/opt/go/src/internal/poll/fd_poll_runtime.go:89
#	0x4dd127	internal/poll.(*FD).Read+0x267							/opt/go/src/internal/poll/fd_unix.go:164
#	0x52c104	net.(*netFD).Read+0x24								/opt/go/src/net/fd_posix.go:55
#	0x53cba4	net.(*conn).Read+0x44								/opt/go/src/net/net.go:179
#	0x4b670f	io.ReadAtLeast+0x8f								/opt/go/src/io/io.go:335
#	0x9f91c7	io.ReadFull+0x267								/opt/go/src/io/io.go:354
#	0x9f9189	golang.org/x/net/internal/socks.(*UsernamePassword).Authenticate+0x229		/root/go/pkg/mod/golang.org/x/[email protected]/internal/socks/socks.go:305
#	0x9f5d42	golang.org/x/net/internal/socks.(*Dialer).connect+0x702				/root/go/pkg/mod/golang.org/x/[email protected]/internal/socks/client.go:79
#	0x9f78e4	golang.org/x/net/internal/socks.(*Dialer).DialContext+0x404			/root/go/pkg/mod/golang.org/x/[email protected]/internal/socks/socks.go:172
#	0xb5088a	github.com/wangluozhe/requests/transport.(*connectDialer).DialContext+0x8a	/root/go/pkg/mod/github.com/wangluozhe/[email protected]/transport/connect.go:125
#	0xb532d7	github.com/wangluozhe/requests/transport.(*roundTripper).dialTLS+0x157		/root/go/pkg/mod/github.com/wangluozhe/[email protected]/transport/roundtripper.go:82
#	0xb53088	github.com/wangluozhe/requests/transport.(*roundTripper).getTransport+0x1a8	/root/go/pkg/mod/github.com/wangluozhe/[email protected]/transport/roundtripper.go:59
#	0xb52e64	github.com/wangluozhe/requests/transport.(*roundTripper).RoundTrip+0x164	/root/go/pkg/mod/github.com/wangluozhe/[email protected]/transport/roundtripper.go:42
#	0xae0baf	github.com/wangluozhe/fhttp.send+0x58f						/root/go/pkg/mod/github.com/wangluozhe/[email protected]/client.go:251
#	0xae04b7	github.com/wangluozhe/fhttp.(*Client).send+0x97					/root/go/pkg/mod/github.com/wangluozhe/[email protected]/client.go:175
#	0xae2b1b	github.com/wangluozhe/fhttp.(*Client).do+0x91b					/root/go/pkg/mod/github.com/wangluozhe/[email protected]/client.go:717
#	0xb60835	github.com/wangluozhe/fhttp.(*Client).Do+0xfb5					/root/go/pkg/mod/github.com/wangluozhe/[email protected]/client.go:585
#	0xb60823	github.com/wangluozhe/requests.(*Session).Send+0xfa3				/root/go/pkg/mod/github.com/wangluozhe/[email protected]/sessions.go:445
#	0xb5f80f	github.com/wangluozhe/requests.(*Session).Request+0x16f				/root/go/pkg/mod/github.com/wangluozhe/[email protected]/sessions.go:247
#	0xb5e529	github.com/wangluozhe/requests.Request+0x49					/root/go/pkg/mod/github.com/wangluozhe/[email protected]/api.go:11
...

aj3423 avatar Oct 23 '23 02:10 aj3423