diff --git a/dialer.go b/dialer.go index d1654aa31..a8e4c1893 100644 --- a/dialer.go +++ b/dialer.go @@ -18,6 +18,7 @@ package quickfix import ( "fmt" "net" + "time" "golang.org/x/net/proxy" @@ -27,8 +28,16 @@ import ( func loadDialerConfig(settings *SessionSettings) (dialer proxy.Dialer, err error) { stdDialer := &net.Dialer{} if settings.HasSetting(config.SocketTimeout) { - if stdDialer.Timeout, err = settings.DurationSetting(config.SocketTimeout); err != nil { - return + timeout, err := settings.DurationSetting(config.SocketTimeout) + if err != nil { + timeoutInt, err := settings.IntSetting(config.SocketTimeout) + if err != nil { + return stdDialer, err + } + + stdDialer.Timeout = time.Duration(timeoutInt) * time.Second + } else { + stdDialer.Timeout = timeout } } dialer = stdDialer diff --git a/session_factory.go b/session_factory.go index 3a6be68a5..c0ac33417 100644 --- a/session_factory.go +++ b/session_factory.go @@ -361,47 +361,59 @@ func (f sessionFactory) buildInitiatorSettings(session *session, settings *Sessi session.ReconnectInterval = 30 * time.Second if settings.HasSetting(config.ReconnectInterval) { - - interval, err := settings.IntSetting(config.ReconnectInterval) + interval, err := settings.DurationSetting(config.ReconnectInterval) if err != nil { - return err + intervalInt, err := settings.IntSetting(config.ReconnectInterval) + if err != nil { + return err + } + + session.ReconnectInterval = time.Duration(intervalInt) * time.Second + } else { + session.ReconnectInterval = interval } - if interval <= 0 { + if session.ReconnectInterval <= 0 { return errors.New("ReconnectInterval must be greater than zero") } - - session.ReconnectInterval = time.Duration(interval) * time.Second } session.LogoutTimeout = 2 * time.Second if settings.HasSetting(config.LogoutTimeout) { - - timeout, err := settings.IntSetting(config.LogoutTimeout) + timeout, err := settings.DurationSetting(config.LogoutTimeout) if err != nil { - return err - } + timeoutInt, err := settings.IntSetting(config.LogoutTimeout) + if err != nil { + return err + } - if timeout <= 0 { - return errors.New("LogoutTimeout must be greater than zero") + session.LogoutTimeout = time.Duration(timeoutInt) * time.Second + } else { + session.LogoutTimeout = timeout } - session.LogoutTimeout = time.Duration(timeout) * time.Second + if session.LogoutTimeout <= 0 { + return errors.New("LogonTimeout must be greater than zero") + } } session.LogonTimeout = 10 * time.Second if settings.HasSetting(config.LogonTimeout) { - - timeout, err := settings.IntSetting(config.LogonTimeout) + timeout, err := settings.DurationSetting(config.LogonTimeout) if err != nil { - return err + timeoutInt, err := settings.IntSetting(config.LogonTimeout) + if err != nil { + return err + } + + session.LogonTimeout = time.Duration(timeoutInt) * time.Second + } else { + session.LogonTimeout = timeout } - if timeout <= 0 { + if session.LogonTimeout <= 0 { return errors.New("LogonTimeout must be greater than zero") } - - session.LogonTimeout = time.Duration(timeout) * time.Second } return f.configureSocketConnectAddress(session, settings)