Thread: RE: [Quickfix-developers] RE: Session *NOT* Resetting
Brought to you by:
orenmnero
|
From: Steinberg, J. <Jon...@bo...> - 2006-03-08 18:37:50
|
I'll try giving it a shot.
In the meantime, tell me if this analysis is reasonable:
Assuming (according to your response) that it is checkSessionTime which
is responsible for triggering the reset:
bool checkSessionTime( const UtcTimeStamp& time )
{
UtcTimeStamp creationTime = m_state.getCreationTime();
return m_sessionTime.isSameSession(time, creationTime);
}
I see it depends on
m_sessionTime.isSameSession:
bool isSameSession( const UtcTimeStamp& time1, const UtcTimeStamp& time2
)
{
if( m_startDay < 0 && m_endDay < 0 )
return isSameSession( m_startTime, m_endTime, time1, time2 );
else
return isSameSession
( m_startTime, m_endTime, m_startDay, m_endDay, time1, time2 );
}
now since I am not using week-long sessions, the call to
isSameSession( m_startTime, m_endTime, time1, time2 );
is used.
My session start time is 10:00 (5 am est)
My session end time is 02:00:00 (9 pm est)
bool SessionTime::isSameSession( const UtcTimeOnly& start,
const UtcTimeOnly& end,
const UtcTimeStamp& time1,
const UtcTimeStamp& time2 )
{ QF_STACK_PUSH(SessionTime::isSameSession)
if( !isSessionTime( start, end, time1 ) ) return false;
if( !isSessionTime( start, end, time2 ) ) return false;
if( time1 == time2 ) return true;
UtcDate time1Date( time1 );
UtcDate time2Date( time2 );
if( start < end || start == end )
return time1Date == time2Date;
else if( start > end )
return labs( time1 - time2 ) < DateTime::SECONDS_PER_DAY;
return false;
QF_STACK_POP
}
Since start > end, the session will always restart when
return labs( time1 - time2 ) < DateTime::SECONDS_PER_DAY;
which means that the session will always get reset at exactly 24 hours
after the last session creation, but *not* at session start time., which
is a problem;
Day one, my session starts at 5:00:14.
Next day, the session starts up at 5:00:11. 3 sconds later it's
resetting itself, causing my problems.
Am I right, or am I left?
Assuming this is correct, I am going to work around it by changing the
session end time to 11:59:00,
thus having start<end in isSameSession and my session will not reset
during the same day (time1Date == time2Date) .
Please let me know if this is correct. My dropped sessions are driving
me nuts.
Thanks for the help
Jonathan Steinberg
-----Original Message-----
From: Oren Miller [mailto:or...@qu...]
Sent: Wednesday, March 08, 2006 9:40 AM
To: Steinberg, Jonathan
Cc: John Hensley; qui...@li...
Subject: Re: [Quickfix-developers] RE: Session *NOT* Resetting
Can you log what is going on in checkSessionTime?
--oren
Steinberg, Jonathan wrote:
> I think I fixed my original problem, but I'm still having issues with
> the reliability of my sessions.
>
> (QuckFix 1.11.0 C# application using quickfix_net wrapper dll, VS
> 2003, Windows 2003 server)
>
> Here's what happened today.
>
> When My session started up at 5 AM , apparently the session did not
> get reset;
>
> Here's the event log:
>
> 2006-03-06 05:00:11.290 Connecting to xx.xx.xx.xxx on port yyyy
>
> 2006-03-06 05:00:12.353 Connection succeeded
>
> 2006-03-06 05:00:15.050 PURGING MESSAGES
>
> 2006-03-06 05:00:15.067 Updating Session: Old Session creation time
> :Mar 3 2006 10:00AM
>
> 2006-03-06 05:00:15.067 UPDATING SESSION INFO: CreationTime Mar 6 2006
> 10:00AM incoming seq: 1 outgoing seq: 1
>
> 2006-03-06 05:00:16.993 Initiated logon request
>
> 2006-03-06 05:00:17.290 Received logon response
>
> 2006-03-06 18:00:01.097 Received logout request
>
> 2006-03-06 18:00:01.173 Sending logout response
>
> 2006-03-06 18:00:01.173 Disconnecting
>
> 2006-03-06 18:00:01.220 Socket Error
>
> 2006-03-06 18:00:11.000 Connecting to xx.xx.xx.xxx on port yyyy
>
> 2006-03-06 18:00:12.047 Connection failed
>
> (The Purging messages and updating session entries are the logging I
> added to diagnose my earlier problem (The 10:AM in the log msgs really
> is 5:AM ET- I left the UTC in the log message))
>
> Here are my incoming and outgoing logs (I'm BFPG the counterparty is
BOFA)
>
> 2006-03-07 05:00:12.803
>
8=FIX.4.09=6135=A34=78249=BFPG52=20060307-10:00:1256=BOFA98=0108=6010=20
3
>
> 2006-03-07 05:00:13.227
>
8=FIX.4.09=6435=A49=BOFA56=BFPG34=143=N52=20060307-10:00:1298=0108=6010=
081
>
> 2006-03-07 05:00:14.540
> 8=FIX.4.09=10035=534=78349=BFPG52=20060307-10:00:1456=BOFA58=MsgSeqNum
> too low, expecting 932 but received 110=211
>
> 2006-03-07 05:00:14.650
>
8=FIX.4.09=6335=249=BOFA56=BFPG34=243=N52=20060307-10:00:127=116=78110=0
17
>
> 2006-03-07 05:00:43.177
>
8=FIX.4.09=5935=A34=149=BFPG52=20060307-10:00:4356=BOFA98=0108=6010=102
>
> 2006-03-07 05:00:43.320
>
8=FIX.4.09=17635=549=BOFA56=BFPG34=343=N52=20060307-10:00:4358=Catastrop
ic
> Error: Incoming sequence number (1) is less than expected (784)
> without PossDupFlag being set. Logging out.10=051
>
> 2006-03-07 05:00:43.413
> 8=FIX.4.09=4749=35=534=2BFPG52=20060307-10:00:4356=BOFA10=060
>
> Here is how I read this:
>
> The session did not reset at 5, but rather tried to logon with the
> prior sequence numbers.
>
> This caused my session to reject the counter party's logon response,
> which had properly reset their sequence number 1.
>
> At the same time, the counter party sends a resend request.
>
> All this happens before 05:00:15
>
> Then suddenly at 05:00:15 the session does reset itself, causing the
> counter party to reject, as it's not expecting it now.
>
> Why is the session not resetting at the session start time?
>
> Any help would be much appreciated.
>
> Jonathan Steinberg
>
|
|
From: Yihu F. <Yih...@re...> - 2006-03-10 03:26:36
Attachments:
SessionTimeTestCase.cpp.diff.txt
|
LS0tIFNlc3Npb25UaW1lLmNwcAkyMDA2LTAzLTA5IDIyOjA4OjQ5LjA2MDUyNTIwMCAtMDUwMAor KysgU2Vzc2lvblRpbWUuY3BwLm5ldwkyMDA2LTAzLTA5IDIxOjU4OjQ1LjU5ODgwNzIwMCAtMDUw MApAQCAtMTEyLDcgKzExMiwyMSBAQAogICAgIGlmKCBzdGFydCA8IGVuZCB8fCBzdGFydCA9PSBl bmQgKQogICAgICAgcmV0dXJuIHRpbWUxRGF0ZSA9PSB0aW1lMkRhdGU7CiAgICAgZWxzZSBpZigg c3RhcnQgPiBlbmQgKQotICAgICAgcmV0dXJuIGxhYnMoIHRpbWUxIC0gdGltZTIgKSA8IERhdGVU aW1lOjpTRUNPTkRTX1BFUl9EQVk7CisJeworCQlVdGNUaW1lT25seSB0aW1lMlRpbWVPbmx5ID0g VXRjVGltZU9ubHkodGltZTIpOw0KKwkJbG9uZyBkZWx0YSA9IHRpbWUyVGltZU9ubHkgLSBzdGFy dDsNCisJCWlmIChkZWx0YSA8IDApDQorCQkJZGVsdGEgPSBEYXRlVGltZTo6U0VDT05EU19QRVJf REFZICsgZGVsdGE7DQorDQorCQlpbnQgc2Vzc2lvbkxlbmd0aCA9IERhdGVUaW1lOjpTRUNPTkRT X1BFUl9EQVkgLSAoc3RhcnQgLSBlbmQpOw0KKwkJYm9vbCByZXN1bHQ7DQorCQlpZiAodGltZTEg PiB0aW1lMikNCisJCQlyZXN1bHQgPSAodGltZTEgLSB0aW1lMikgPCAoc2Vzc2lvbkxlbmd0aCAt IGRlbHRhKTsNCisJCWVsc2UNCisJCQlyZXN1bHQgPSAodGltZTIgLSB0aW1lMSkgPCBzZXNzaW9u TGVuZ3RoOw0KKwkJcmV0dXJuIHJlc3VsdDsKKyAgICAgIC8vIHJldHVybiBsYWJzKCB0aW1lMSAt IHRpbWUyICkgPCBEYXRlVGltZTo6U0VDT05EU19QRVJfREFZOworCX0KICAgICByZXR1cm4gZmFs c2U7CiAKICAgICBRRl9TVEFDS19QT1AK |
|
From: Oren M. <or...@qu...> - 2006-03-15 07:27:26
|
Thank you very much for providing unit tests. This patch has been added to CVS. --oren Yihu Fang wrote: > Jonathan, > > From the example you provided, I did a unit test and indeed it looks > like that the isSameSession() does not pass the test. > >>> My session start time is 10:00 (5 am est) > >>> My session end time is 02:00:00 (9 pm est) > >>> Day one, my session starts at 5:00:14. Next day, the session starts > up at 5:00:11.. > > // start time is greater than end time > > start = UtcTimeOnly( 10, 0, 0 ); > > end = UtcTimeOnly( 2, 0, 0 ); > > // same session time 1 is in next day > > time1 = UtcTimeStamp( 10, 0, 11, 9, 3, 2006 ); > > time2 = UtcTimeStamp( 10, 0, 14, 8, 3, 2006 ); > > assert( !SessionTime::isSameSession( start, end, time1, time2 ) ); > > As you noticed that when the startTime is ahead of endTime (next day), > the following simple check in method isSameSession() is not valid > > return labs( time1 - time2 ) < DateTime::SECONDS_PER_DAY; > > Because the current time2 (creation time) could be at any where within > the session window between start and end. A simple compare of current > time (time1) and creation time (time2) is not enough. A bit more check > to ensure that the (time1 – time2) is within the session window is needed. > > Attached please find the patch of SessionTime.cpp. I also provide some > more unit test cases in SessionTimeTestCase.cpp. The patch seems to > solve the problem and it also passes all the unit tests. > > Thanks, > > -Yihu > > > > To find out more about Reuters visit www.about.reuters.com > > Any views expressed in this message are those of the individual > sender, except where the sender specifically states them to be the > views of Reuters Ltd. > >------------------------------------------------------------------------ > >--- SessionTime.cpp 2006-03-09 22:08:49.060525200 -0500 >+++ SessionTime.cpp.new 2006-03-09 21:58:45.598807200 -0500 >@@ -112,7 +112,21 @@ > if( start < end || start == end ) > return time1Date == time2Date; > else if( start > end ) >- return labs( time1 - time2 ) < DateTime::SECONDS_PER_DAY; >+ { >+ UtcTimeOnly time2TimeOnly = UtcTimeOnly(time2); >+ long delta = time2TimeOnly - start; >+ if (delta < 0) >+ delta = DateTime::SECONDS_PER_DAY + delta; >+ >+ int sessionLength = DateTime::SECONDS_PER_DAY - (start - end); >+ bool result; >+ if (time1 > time2) >+ result = (time1 - time2) < (sessionLength - delta); >+ else >+ result = (time2 - time1) < sessionLength; >+ return result; >+ // return labs( time1 - time2 ) < DateTime::SECONDS_PER_DAY; >+ } > return false; > > QF_STACK_POP > > >------------------------------------------------------------------------ > >--- SessionTimeTestCase.cpp 2006-03-09 22:15:01.300718300 -0500 >+++ SessionTimeTestCase.cpp.new 2006-03-09 21:58:11.680373100 -0500 >@@ -190,6 +190,31 @@ > time2 = UtcTimeStamp( 19, 06, 0, 1, 14, 2004 ); > assert( !SessionTime::isSameSession( start, end, time1, time2 ) ); > assert( !SessionTime::isSameSession( start, end, time2, time1 ) ); >+ >+ // start time is greater than end time >+ start = UtcTimeOnly( 10, 0, 0 ); >+ end = UtcTimeOnly( 2, 0, 0 ); >+ >+ // same session time 1 is in next day >+ time1 = UtcTimeStamp( 10, 0, 11, 9, 3, 2006 ); >+ time2 = UtcTimeStamp( 10, 0, 14, 8, 3, 2006 ); >+ assert( !SessionTime::isSameSession( start, end, time1, time2 ) ); >+ >+ // same session time 1 is in next day >+ start = UtcTimeOnly( 16, 0, 0 ); >+ end = UtcTimeOnly( 15, 0, 0 ); >+ >+ time1 = UtcTimeStamp( 14, 0, 0, 9, 3, 2006 ); >+ time2 = UtcTimeStamp( 1, 0, 0, 9, 3, 2006 ); >+ assert (SessionTime::isSameSession( start, end, time1, time2 ) ); // yes >+ time2 = UtcTimeStamp( 23, 0, 0, 8, 3, 2006 ); >+ assert( SessionTime::isSameSession( start, end, time1, time2 ) ); // yes >+ >+ time1 = UtcTimeStamp( 17, 0, 0, 9, 3, 2006 ); >+ time2 = UtcTimeStamp( 1, 0, 0, 9, 3, 2006 ); >+ assert( !SessionTime::isSameSession( start, end, time1, time2 ) ); // no >+ time2 = UtcTimeStamp( 23, 0, 0, 8, 3, 2006 ); >+ assert( !SessionTime::isSameSession( start, end, time1, time2 ) ); // no > } > > void SessionTimeTestCase::isSameSessionWithDay::onRun( SessionTime& object ) > > |