[Quickfix-developers] Duplicate logon attempt handling
Brought to you by:
orenmnero
From: Daniel M. <Dan...@ma...> - 2003-11-06 18:33:02
|
Howard, Did any one get back to you on this ? The current (non QuickFix) servers I connect to do not even allow multiple connections from a client app already connected to a given port, they block it at the socket connection level. QuickFix is designed to accept multiple connections on the same port, with the Sender,Target, and BeginString being unique for each session.=20 Here is what the spec says about rejecting a logon: * The initiator sends a Logon message. The acceptor will authenticate the identity of the initiator by examining the Logon message. The Logon message will contain the data necessary to support the previously agreed upon authentication method. If the initiator is successfully authenticated, the acceptor responds with a Logon message. If authentication fails, the session acceptor should shut down the connection after optionally sending a Logout message to indicate the reason of failure. Sending a Logout in this case is not required because doing so would consume a sequence number for that session, which in some cases may be problematic. The session initiator may begin to send messages immediately following the Logon message, however, the acceptor may not be ready to receive them. The initiator must wait for the confirming Logon message from the acceptor before declaring the session fully established. In regards to QuickFix, I made a modification in Acceptor.cpp to reject any logon message if the session trying to logon is already logged on: line:149 Sessions::iterator i =3D m_sessions.find( sessionID ); if ( i !=3D m_sessions.end() ) { // we have a logon message, we found a session defined for it, // now see if this session isLoggedOn, if so, drop it if(i->second->isLoggedOn()) return 0; i->second->setResponder( &responder ); return i->second; } Ideally, I would like to send the second session a Logout message with text in the message explaining why, but that is a little more complicated. I have not checked this in, as I am not sure what Oren thinks of it. Daniel Reply-To: ho...@ex... To: QuickFIX Questions <qui...@li...> Organization: E-xchange Advantage Date: Tue, 04 Nov 2003 13:42:30 -0500 Subject: [Quickfix-developers] Duplicate logon attempt handling --=3D-AsZnvoI7U1AYW73moz1y Content-Type: text/plain Content-Transfer-Encoding: 7bit Testing my fix server under the following circumstances seems to put quickfix into an erratic state. A user logons on with a SessionId (FIX.4.2:SBI0->SLGM0) and sends in some orders. Then that users starts a second logon with the same SessionID. I never see this second Logon attempt in my App class's fromAdmin or onLogon overrides, however, my App class does receive the onLogout event twice (both times with the same SessionID). Furthermore, the second session is disconnected, however I continue to see heartbeats being received from the User's First fix client in the FIX incoming log, however I do not receive these in the fromAdmin override, and I do not see anything in my FIX outgoing log. Ideally, in this situation, if I receive a Logon Request for a Session that I currently belive to be alive, I would like to drop the first session, and then handle the LogonRequest.=20 If not that, then I'd at least like to be able to Reject the second logon attempt. However, since I never receive the fromAdmin it doesn't seem like there's anything I can do either way. Any help would be appreciated. Thanks, -H --=3D-AsZnvoI7U1AYW73moz1y Content-Type: text/html; charset=3Dutf-8 Content-Transfer-Encoding: 7bit <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN"> <HTML> <HEAD> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = CHARSET=3DUTF-8"> <META NAME=3D"GENERATOR" CONTENT=3D"GtkHTML/3.0.9"> </HEAD> <BODY> = Testing my fix server under the following circumstances seems to put quickfix into an erratic state.<BR> <BR> A user logons on with a SessionId (FIX.4.2:SBI0->SLGM0) and sends in some orders.<BR> <BR> Then that users starts a second logon with the same SessionID.<BR> <BR> I never see this second Logon attempt in my App class's fromAdmin or onLogon overrides,<BR> however, my App class does receive the onLogout event twice (both times with the same SessionID).<BR> <BR> Furthermore, the second session is disconnected, however I continue to see heartbeats being received <BR> from the User's First fix client in the FIX incoming log, however I do not receive these in the <BR> fromAdmin override, and I do not see anything in my FIX outgoing log.<BR> <BR> Ideally, in this situation, if I receive a Logon Request for a Session that I currently belive to be alive, I <BR> would like to drop the first session, and then handle the LogonRequest. If not that, then I'd at least like to be<BR> able to Reject the second logon attempt. However, since I never receive the fromAdmin it doesn't seem like<BR> there's anything I can do either way.<BR> <BR> Any help would be appreciated.<BR> <BR> Thanks,<BR> <BR> -H<BR> <BR> </BODY> </HTML> --=3D-AsZnvoI7U1AYW73moz1y-- --__--__-- Message: 2 From: Brian Egge <Br...@ma...> To: 'Joerg Thoennes' <Joe...@ma...>, Oren Miller <ore...@ya...>, "'qui...@li...'" <qui...@li...> Date: Tue, 4 Nov 2003 15:29:13 -0500 Subject: [Quickfix-developers] Additional test cases for ParserTestCase::extractLength In ParserTestCase.h: class extractLength : public Test { bool onSetup( Parser*& pObject ); void onRun( Parser& object ); std::string m_normalLength; std::string m_badLength; std::string m_negativeLength; // New Code Start std::string m_incomplete_1; std::string m_incomplete_2; // New Code End } In ParserTestCase.cpp: bool ParserTestCase::extractLength::onSetup( Parser*& pObject ) { m_normalLength =3D3D =3D "8=3D3DFIX.4.2\0019=3D3D12\00135=3D3DA\001108=3D3D30\00110=3D3D31\001"; m_badLength =3D3D =3D "8=3D3DFIX.4.2\0019=3D3DA\00135=3D3DA\001108=3D3D30\00110=3D3D31\001"; m_negativeLength =3D3D =3D "8=3D3DFIX.4.2\0019=3D3D-1\00135=3D3DA\001108=3D3D30\00110=3D3D31\001"; // New Code Start m_incomplete_1 =3D3D "8=3D3DFIX.4.2"; m_incomplete_2 =3D3D "8=3D3DFIX.4.2\0019=3D3D12"; // New Code End return true; } void ParserTestCase::extractLength::onRun( Parser& object ) { int length =3D3D 0; std::string::size_type pos =3D3D 0; assert( object.extractLength(length, pos, m_normalLength) ); assert( length =3D3D=3D3D 12 ); assert( pos =3D3D=3D3D 15 ); // Add this line: pos =3D3D 0; try { object.extractLength(length, pos, m_badLength); assert(false); } catch( MessageParseError& ) {} // Add this line: assert(pos =3D3D=3D3D 0); try { object.extractLength(length, pos, m_negativeLength); assert(false); } catch( MessageParseError& ) {} // New Code Start assert(pos =3D3D=3D3D 0); try { assert( object.extractLength(length, pos, m_incomplete_1) =3D3D=3D3D =3D false); assert(pos =3D3D=3D3D 0); } catch( MessageParseError& ) { assert(false) } =3D09 try { assert( object.extractLength(length, pos, m_incomplete_2) =3D3D=3D3D =3D false); assert(pos =3D3D=3D3D 0); } catch( MessageParseError& ) { assert(false) } // New Code End assert( !object.extractLength(length, pos, "") ); } -----Original Message----- From: Joerg Thoennes [mailto:Joe...@ma...] Sent: Monday, November 03, 2003 11:12 AM To: Oren Miller Cc: Brian Egge; 'Miller, Oren'; 'qui...@li...' Subject: Re: [Quickfix-developers] BodyLength or CheckSum missing Oren Miller wrote: > Post you're fix to the developers list and someone > will check it in. It would be a good idea to update > the test case to reflect this problem. Do you have a > test case that will make the old code fail but is > succesfull with your code? Something like this will > allow us to get it into the codebase quicker. Thanks! I already thought of checking this in, but was lacking the test case. So if you have a test case, Brian, I could do the check-in. Cheers, J=3DF6rg > --- Brian Egge <Br...@ma...> wrote: >=3D20 >>I think I have found the problem that is causing >>this error. The error only >>surfaces when the 8=3D3DFix is received, but the >>9=3D3Dlength has not been. >> >>The problem is in Parser.cpp: >> >>bool Parser::extractLength( int& length, >>std::string::size_type& pos, >> const std::string& >>buffer ) >>throw( MessageParseError& ) >>{ QF_STACK_PUSH(Parser::extractLength) >> >> if( !buffer.size() ) return false; >> =3D20 >> std::string::size_type startPos =3D3D buffer.find( >>"\0019=3D3D", 0 ); >> if( pos =3D3D=3D3D std::string::npos ) return false; >>// This should be: >>// if( startPos =3D3D=3D3D std::string::npos ) return >>false; >>// >> startPos +=3D3D 3; >> std::string::size_type endPos =3D3D buffer.find( >>"\001", startPos ); >>// This should be: >>// if( endPos =3D3D=3D3D std::string::npos ) return false; >>// >> pos =3D3D endPos + 1; >> >>What happens with the current code is strLength gets >>set to 'FIX.4.x'. This >>raises and exception and throws a MessageParseError. >> >>I'd like to get this fix checked in to CVS. I >>haven't used CVS before, and >>I don't know who is given access to check in >>changes. >> >>Brian=3D20 >> >> >>-----Original Message----- >>From: Miller, Oren >>[mailto:OM...@ri...] >>Sent: Tuesday, October 14, 2003 6:02 PM >>To: Br...@ma...; >>qui...@li... >>Subject: Re: [Quickfix-developers] BodyLength or >>CheckSum missing >> >> >>Do yo have an example of a message that causes this >>error? >> >>-------------------------- >>Sent from my BlackBerry Wireless Handheld >> >> >>-----Original Message----- >>From: Brian Egge <Br...@ma...> >>To: qui...@li... >><qui...@li...> >>Sent: Tue Oct 14 10:10:55 2003 >>Subject: [Quickfix-developers] BodyLength or >>CheckSum missing >> >>I seem to be having a problem where I get an >>InvalidMessage("BodyLength or >>CheckSum missing") exception thrown from >>Message::validate(). When I look >>at my logs, or even re-parse the message, everything >>is in tact. I can't >>see any reason why this exception is being thrown.=3D20 >>I only get this with one >>venue, and it only happens every couple of days or >>so. Has anyone else had >>this problem before? >> >>I've added some more logging to this area, and I >>think I will figure it out >>soon. The item that concerns me more is that this >>exception does not get >>handled, and the EH eventually calls terminate() or >>abort() and the program >>ends. I'm using version 1.6, and I have two >>suggestions. >> >>1) "bool SocketConnection::read( SocketAcceptor& a, >>SocketServer& s )" has >>an exception handler, while bool >>"SocketConnection::read( SocketConnector& s >>)" does not. My exception occurs in the latter >>case. I copied the >>exception code from the one read to the other to >>make them consistent. >> >>2) I added try {} catch(...) statement to the >>onStart() procedures, to trap >>any unhanded exceptions. I'd rather have the >>thread safely terminate than >>for my whole app to end. =3D20 >> >>If these changes are worthwhile, I'll try to merge >>them in CVS.=3D20 >> >>-Brian >> >> >> >=3D20 > ------------------------------------------------------- >=3D20 >>This SF.net email is sponsored by: SF.net Giveback >>Program. >>SourceForge.net hosts over 70,000 Open Source >>Projects. >>See the people who have HELPED US provide better >>services: >>Click here: http://sourceforge.net/supporters.php >>_______________________________________________ >>Quickfix-developers mailing list >>Qui...@li... >> >=3D20 > https://lists.sourceforge.net/lists/listinfo/quickfix-developers >=3D20 >> >> > ------------------------------------------------------- >=3D20 >>This SF.net email is sponsored by: SF.net Giveback >>Program. >>Does SourceForge.net help you be more productive?=3D20 >>Does it >>help you create better code? SHARE THE LOVE, and >>help us help >>YOU! Click Here: http://sourceforge.net/donate/ >>_______________________________________________ >>Quickfix-developers mailing list >>Qui...@li... >> >=3D20 > https://lists.sourceforge.net/lists/listinfo/quickfix-developers >=3D20 >=3D20 > __________________________________ > Do you Yahoo!? > Exclusive Video Premiere - Britney Spears > http://launch.yahoo.com/promos/britneyspears/ >=3D20 >=3D20 > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Quickfix-developers mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfix-developers >=3D20 --=3D20 Joerg Thoennes http://macd.com Tel.: +49 (0)241 44597-24 Macdonald Associates GmbH Fax : +49 (0)241 44597-10 Lothringer Str. 52, D-52070 Aachen --__--__-- Message: 3 From: Brian Egge <Br...@ma...> To: "'qui...@li...'" <qui...@li...> Date: Tue, 4 Nov 2003 15:50:45 -0500=20 Subject: [Quickfix-developers] UtcTimeStamp additions / tests Recently I've found a need to use the tm_yday member in the struct tm, used by the UtcTimeStamp class. The strptime.c does not calculate or clear this member. I've added this code at the bottom of strptime.c to calcuate this value: char isLeapYear; int mon,year; ... // Fix up yday field year =3D tm->tm_year + 1900; isLeapYear =3D (year%4=3D=3D0) - (year%100=3D=3D0) + (year%400=3D=3D0) = - (year%4000=3D=3D0); mon =3D tm->tm_mon; // 0 =3D=3D January tm->tm_yday =3D=20 (mon>0)*31 + // Jan (mon>1)*(28+isLeapYear) + // Feb (mon>2)*31 + // March (mon>3)*30 + // April (mon>4)*31 + // May (mon>5)*30 + // June (mon>6)*31 + // July (mon>7)*31 + // Aug (mon>8)*30 + // Sept (mon>9)*31 + // Oct (mon>10)*30 + // Nov + tm->tm_mday - 1; In FieldType.h, I've added to the UtcTimeStamp class: int getYday() const { return tm_yday + 1; } and to the UtcDate class: int getYday() const { return UtcTimeStamp::getYday(); } I've added two test cases to FieldConvertsTestCase.cpp: void FieldConvertorsTestCase::utcTimeStampConvertFrom::onRun( void*& ) { ... assert( result.getYday() =3D=3D 117 ); } void FieldConvertorsTestCase::utcDateConvertFrom::onRun( void*& ) { ... assert( result.getYday() =3D=3D 117 ); } I was not able to contact the author of strptime.c to submit this addition. --__--__-- _______________________________________________ Quickfix-developers mailing list Qui...@li... https://lists.sourceforge.net/lists/listinfo/quickfix-developers End of Quickfix-developers Digest |