Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can´t connect to initiator (QuickFix .NET wrapper -> QuickFixN) #53

Closed
kwitee opened this issue Mar 21, 2012 · 6 comments
Closed

Can´t connect to initiator (QuickFix .NET wrapper -> QuickFixN) #53

kwitee opened this issue Mar 21, 2012 · 6 comments

Comments

@kwitee
Copy link

kwitee commented Mar 21, 2012

I was using .NET wrapper for quickfix and everything worked fine. Recently I was looking for a native alternative and I found this project. So I took my old project and basicly rewrite it. But now it seems that my initiator can´t even get a working connection since the OnLogon event is never called. My configuration file is still the same:

[DEFAULT]

ConnectionType=initiator

LogonTimeout=1
LogoutTimeout=1

ValidateFieldsOutOfOrder=Y
ValidateUserDefinedFields=Y
ValidateFieldsHaveValues=Y
AllowUnknownMsgFields=Y
SocketTcpNoDelay=Y

FileStorePath=Store
FileLogPath=Log

CheckLatency=N
CheckCompID=Y

SendRedundantResendRequests=Y
ContinueInitializationOnError=Y

ResetOnLogon=Y
ResetOnLogout=Y
ResetOnDisconnect=Y
ForceResync=Y

HeartBtInt=30
StartTime=03:00:00
EndTime=22:00:00
UseLocalTime=Y

ReconnectInterval=20

UseDataDictionary=Y
DataDictionary=FXService.FXCM.xml

BeginString=FIX.4.4

[SESSION]

username=xxx
password=xxx
pin=xxx

SenderCompID=xxx
TargetCompID=xxx
TargetSubID=xxx

SocketConnectHost=fixdemo.fxcorporate.com
SocketConnectPort=8043

I don't know if this is a proper channel for this kind of problem but I appreciate any help.

@kwitee
Copy link
Author

kwitee commented Mar 21, 2012

I tried to debug both old and new solutions, here are my results:
Old .NET QuickFix wrapper:

  • OnCreate event is called after calling the constructor of initiator,
  • calling start method
  • toAdmin event fires and initiates the connection - with the new API this event is never called so I guess there is some kind of socket error but no exceptions are called.

@kwitee
Copy link
Author

kwitee commented Mar 21, 2012

I think I found the error in method SocketInitiator.OnStart:

Environment.TickCount is returning negative number on my system so the Connect method is never called.
I think this should be considered as bug since TickCount can return negative number:

"The value of this property is derived from the system timer and is stored as a 32-bit signed integer. Consequently, if the system runs continuously, TickCount will increment from zero to Int32.MaxValue for approximately 24.9 days, then jump to Int32.MinValue, which is a negative number, then increment back to zero during the next 24.9 days."
Source: http://msdn.microsoft.com/en-us/library/system.environment.tickcount.aspx

@kwitee kwitee closed this as completed Mar 21, 2012
@kwitee
Copy link
Author

kwitee commented Mar 21, 2012

Simple solution should fix this issue (my connection work after this change):

    protected override void OnStart()
    {
        shutdownRequested_ = false;

        while(!shutdownRequested_)
        {
            int reconnectIntervalAsTicks = 1000 * reconnectInterval_;
            int nowTickCount = Environment.TickCount;
            if (nowTickCount < 0)
                nowTickCount *= -1;

            if ((nowTickCount - lastConnectTickCount) >= reconnectIntervalAsTicks)
            {
                Connect();
                lastConnectTickCount = nowTickCount;
            }

            Thread.Sleep(1 * 1000);
        }
    }

@gbirchmeier
Copy link
Member

Dupe of #42.

By the way, the proper avenue for help is the mailing list.
http://quickfixn.org/help

Issues are for bug and new-feature tracking.

@kwitee
Copy link
Author

kwitee commented Mar 21, 2012

Thanks for answer. Next time I will use the mailing list. But to be accurate, it was a bug after all ;-) but it taked me more time to realize it...

@gbirchmeier
Copy link
Member

No problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants