This is the initiator config:
[SESSION]
ConnectionType=initiator
BeginString=FIX.4.1
SenderCompID=PS
TargetCompID=ND
SocketNodelay=Y
SocketConnectHost=48.40.87.16
SocketAcceptPort=9840
StartTime=07:00:00
EndTime=22:00:00
FileStorePath=C:/Temp/quickfix/store/initiator
FileLogPath=C:/Temp/quickfix/logs/initiator
ReconnectInterval=30
HeartBtInt=20
SocketReuseAddress=Y
UseDataDictionary=N
# DataDictionary=datadictionary/FIX41.xml
And this is the acceptor config
[SESSION]
ConnectionType=acceptor
BeginString=FIX.4.1
TargetCompID=ND
SenderCompID=PS
SocketNodelay=Y
SocketAcceptPort=9840
StartTime=07:00:00
EndTime=22:00:00
FileStorePath=C:/Temp/quickfix/store/acceptor
FileLogPath=C:/Temp/quickfix/logs/acceptor
SocketReuseAddress=Y
UseDataDictionary=N
I am sending a very simple message:
def create_message(self):
print ("Composing Message")
message = fix.Message();
header = message.getHeader();
header.setField(fix.BeginString("FIX.4.1"))
header.setField(fix.SenderCompID("PS"))
header.setField(fix.TargetCompID("ND"))
header.setField(fix.MsgType("D"))
message.setField(fix.OrigClOrdID("123"))
message.setField(fix.ClOrdID("321"))
message.setField(fix.Symbol("LNUX"))
message.setField(fix.Side('B'))
message.setField(fix.Text("Really Cancel My Order!"))
return message
def test_fix(self):
print ("Testing Fix")
message = self.create_message()
fix.Session.sendToTarget(message, self.sessionID)
print ("Testing FIX ends")
My output on the initiator FIX.4.1-PS-ND.body does have the message it sent. However I am seeing nothing on acceptor. (1) What am I doing wrong/ (2) How does the initiator know where exactly (in this case anyway - TargetCompID=ND) where "ND" is?
I assume you want your initiator and acceptor to connect against each other. That will not work with your config because both have the same TargetCompID
and SenderCompID
.
For this to work, TargetCompID
and SenderCompID
need to be swapped on each end of the connection.
So the acceptor needs to have:
SenderCompID=ND
TargetCompID=PS
As long as both ends are not connected, calls to Session.sendToTarget
will cause the message to be only written to the message store but not sent out. It will get sent out as soon as the session connects.
BTW, your initiator needs no SocketAcceptPort
but a SocketConnectPort
.
That should hopefully connect both ends. If not please paste error message.