Search code examples
pythonc++authenticationquickfixfix-protocol

C++ FIX Implementation --> Invalid user for session. Username and SenderCompId must match


Im developing a bot in c++ using QuickFix, when I send a Logon message I get a logout response saying "Invalid user for session. Username and SenderCompId must match"

This is my message:

8=FIXT.1.1|9=113|35=A|34=1|49=REM4820|52=20201008-22:22:59.886|56=ROFX|553=User|554=pass|98=0|108=30|141=Y|1137=9|10=054|

(User and pass changed for privacy reasons)

This is the response:

8=FIXT.1.1|9=135|35=5|34=1|49=ROFX|52=20201008-22:33:00.356|56=REM4820|1128=9|58=Invalid user for session. Username and SenderCompId must match.|1409=1|10=124|

Things I've tried:

  • I've downloaded this python project and used it to connect with Remarkets getting the same result. (and the same logon message being sent)

  • Interchange SenderCompID and TargetCompID as i saw in another post that it helped someone.

  • Make new users with new passwords to try different accounts, same results.

  • Not sending user and password as Remarkets documentation states it's not necessary: no response from host

  • Played with SSL configuration. I'm using Stunnel4, but I assume that if "Username and SenderCompId must match" the Acceptor must be receiving and reading my message.

  • Ignore SSL and connect directly: Connection reset by peer.

My first and most important quiestion is: What am I doing wrong?

Another questions that might really help:

  • Is there a way for me to connect (OS:ubuntu) using a nice GUI #OrNot and checking FIX message to see the difference between a message that connects and mine that doesn't? Those were my intentions with python but i got the same result.

  • Does someone know about a Remarkets Alternative, blaming it on remarkets is like blaming it on the compiler but I need to check.

  • Why does the server answers field 58 with an explanation but sometimes i get "Connection reset by peer"?

Client.conf

[DEFAULT]
PersistMessages=Y
ConnectionType=initiator 
ReconnectInterval=60
FileLogPath=./Logs/ 
FileStorePath=./Sessions/
UseLocalTime=Y
UseDataDictionary=Y
AppDataDictionary=conf/spec/FIX50SP2_rofex.xml
TransportDataDictionary=conf/spec/FIXT11.xml
StartTime=00:00:00
EndTime=00:00:00
ValidateUserDefinedFields=N
ResetOnLogon=Y
ResetOnLogout=Y
DefaultApplVerID=FIX.5.0SP2

[SESSION]
BeginString=FIXT.1.1
SenderCompID=REM4820
TargetCompID=ROFX
SocketConnectHost=127.0.0.1
SocketConnectPort=9876
HeartBtInt=30

TimeInForce=Day
TradingSessionID=1
ScreenLogShowIncoming=Y
ScreenLogShowOutgoing=Y
ScreenLogEvents=Y
LogoutTimeout=5
LogonTimeout=30
ResetOnDisconnect=Y
RefreshOnLogon=Y
SocketNodelay=N
ValidateFieldsHaveValues=N
ValidateFieldsOutofOrder=N
CheckLatency=N

Solution

  • This is definitely a counterparty-specific-logic problem, and not a FIX protocol problem.

    Let's get extremely literal:

    Username and SenderCompId must match.

    Going by that message alone, it seems pretty clear that tag 49 (SenderCompID) and tag 553 (Username) must have the same value.

    Did they? I'm guessing they didn't. Try setting 553 to match 49.