Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
TransportDataDictionary string = "TransportDataDictionary"
AppDataDictionary string = "AppDataDictionary"
ResetOnLogon string = "ResetOnLogon"
ReconnectInterval string = "ReconnectInterval"
HeartBtInt string = "HeartBtInt"
FileLogPath string = "FileLogPath"
FileStorePath string = "FileStorePath"
Expand Down
6 changes: 6 additions & 0 deletions config/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ If set to N, fields that are out of order (i.e. body fields in the header, or he

Defaults to Y.

ReconnectInterval

Time between reconnection attempts in seconds. Only used for initiators. Value must be positive integer.

Defaults to 30

HeartBtInt

Heartbeat interval in seconds. Only used for initiators. Value must be positive integer.
Expand Down
3 changes: 1 addition & 2 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
)

//Picks up session from net.Conn Initiator
func handleInitiatorConnection(address string, log Log, sessID SessionID, quit chan bool) {
reconnectInterval := 30 * time.Second
func handleInitiatorConnection(address string, log Log, sessID SessionID, quit chan bool, reconnectInterval time.Duration) {
session := activate(sessID)
if session == nil {
log.OnEventf("Session not found for SessionID: %v", sessID)
Expand Down
13 changes: 12 additions & 1 deletion initiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package quickfix

import (
"fmt"
"time"

"github.com/quickfixgo/quickfix/config"
)

Expand Down Expand Up @@ -32,8 +34,17 @@ func (i *Initiator) Start() error {
return fmt.Errorf("error on SocketConnectPort: %v", err)
}

var reconnectInterval int = 30 // Default configuration (in seconds)
if s.HasSetting(config.ReconnectInterval) {
if reconnectInterval, err = s.IntSetting(config.ReconnectInterval); err != nil {
return fmt.Errorf("error on ReconnectInterval: %v", err)
} else if reconnectInterval <= 0 {
return fmt.Errorf("ReconnectInterval must be greater than zero")
}
}

address := fmt.Sprintf("%v:%v", socketConnectHost, socketConnectPort)
go handleInitiatorConnection(address, i.globalLog, sessionID, i.quitChan)
go handleInitiatorConnection(address, i.globalLog, sessionID, i.quitChan, time.Duration(reconnectInterval)*time.Second)
}

return nil
Expand Down