我正在运行golang http客户端来对服务器进行压力测试.有时我收到错误"拨打tcp 161.170.xx.xxx:80:操作超时"错误.
我认为这是HTTP客户端超时.我正在考虑根据/sf/answers/1182711491/增加超时值,但我想先找出golang中的默认超时值.如果它取决于操作系统而不是语言,我如何在Mac OS中检查此值?
According to http://golang.org/pkg/net/#Dialer :
type Dialer struct {
// Timeout is the maximum amount of time a dial will wait for
// a connect to complete. If Deadline is also set, it may fail
// earlier.
//
// The default is no timeout.
//
// With or without a timeout, the operating system may impose
// its own earlier timeout. For instance, TCP timeouts are
// often around 3 minutes.
Run Code Online (Sandbox Code Playgroud)
So the default timeout, without taking into account OS imposed limits is none.
The timeout can be set with SetDeadline.
The default OSX timeout can (I think) be checked with sysctl net.inet.tcp.
| 归档时间: |
|
| 查看次数: |
4994 次 |
| 最近记录: |