0

I am writing a program which sends a security definition request to ICE (message type 35=c) and receives a series of security definition response messages (message type 35=d). Based on the NoRpts tag, I know I am expecting a sequence of 166 messages, each of which contain 100 securities in a repeating group. What is happening is that typically I will receive the first 4-6 messages fine, and then quickfixn throws an error that looks like this:

Session disconnecting: QuickFix.MessageParseError: Could not parse message: Error at position (38753) while parsing msg (<message string excluded for brevity>)
 ---> System.FormatException: The input string '90tural Gas Swing Gas Daily Daily Futures☺9032' was not in a correct format.
   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, ReadOnlySpan`1 value, TypeCode type)
   at QuickFix.Message.ExtractField(String msgstr, Int32& pos, DataDictionary sessionDD, DataDictionary appDD)
   --- End of inner exception stack trace ---
   at QuickFix.Message.ExtractField(String msgstr, Int32& pos, DataDictionary sessionDD, DataDictionary appDD)
   at QuickFix.Message.SetGroup(StringField grpNoFld, String msgstr, Int32 pos, FieldMap fieldMap, IGroupSpec groupDD, DataDictionary sessionDataDictionary, DataDictionary appDD, IMessageFactory msgFactory)
   at QuickFix.Message.SetGroup(StringField grpNoFld, String msgstr, Int32 pos, FieldMap fieldMap, IGroupSpec groupDD, DataDictionary sessionDataDictionary, DataDictionary appDD, IMessageFactory msgFactory)
   at QuickFix.Message.FromString(String msgstr, Boolean validate, DataDictionary sessionDD, DataDictionary appDD, IMessageFactory msgFactory, Boolean ignoreBody)
   at QuickFix.MessageBuilder.Build()
   at QuickFix.Session.Next(MessageBuilder msgBuilder)
   at QuickFix.SocketInitiatorThread.ProcessStream()
   at QuickFix.SocketInitiatorThread.Read()

Basically the string that appears between 2 delimiter characters is "90tural Gas Swing Gas Daily Daily Futures", which is not valid FIX message syntax (I believe the correct tag here is 9063=Natural Gas Swing Gas Daily Daily Futures)

We have opened support tickets with our counter party we are connecting to, and all of their responses indicate that the messages they are sending on their end are correct. Also, every time I run it, it's always a different message number that the program crashes on and it's always a different string that is reported as invalid, which makes me think it's some transient issue associated with reading the data off the stream incorrectly.

Does anyone have any suggestions related to what might be happening or how I can debug this further?

  • Which version of quickfixn are you using? Maybe an older one that doesn't handle special characters or something like that? Looks strange. – Christoph John Apr 01 '23 at 17:34
  • I am referencing version 1.10.0 of QuickFIXn.Core and version 1.10.0 of QuickFIXn.FIX4.4 – mfisher214 Apr 03 '23 at 13:48
  • This is quite strange. Are you able to review the message in a QF message log (NOT a debug print or console write-- never trust those!), and see what character is at the position indicated? – Grant Birchmeier Apr 03 '23 at 17:46
  • @GrantBirchmeier Yes. From QuickFix library I am using a CompositeLogFactory that contains a ScreenLogFactory and a FileLogFactory. The latest exception I got states "The input string '90NG Swing GDD Futures9063' was not in a correct format.", and I can see in both the screen and file outputs the message is genuinely incorrect - here is a section of the message found in the logs: "9071=390NG Swing GDD Futures9063=Natural Gas Swing Gas Daily Daily Futures" – mfisher214 Apr 03 '23 at 19:39
  • Any chance there are unprintable characters in that field where there are not supposed to be? Might need to open the log in plain Vim or a hex editor to see them. – Grant Birchmeier Apr 04 '23 at 04:11
  • @GrantBirchmeier Not seeing any special characters. If I open the message log file in vim I see this sequence in the fix message: "9072=S^A9073=1.0^A9E^A9073=1.0^A9071=2" , where "9E9073" is the invalid string from the error message in the event log file – mfisher214 Apr 04 '23 at 15:50
  • 1
    Problem is most probably the ^A right after 9E. No tag=value. – Christoph John Apr 04 '23 at 17:12
  • Yep, Christoph is on point. I'm not sure what 9E could be, but something is wrong. I'd check with Cargill and ask them to check the message they sent at this timestamp. – Grant Birchmeier Apr 04 '23 at 22:23
  • @GrantBirchmeier We have reached out to ICE, and they say that all of their messages are valid at the time they are sent from their side. Do you have any other suggestions? One other thing I noticed that I'm potentially suspicious of is that the quick fix code is dependent on use of Buffer.BlockCopy when reading data off the stream which is marked as an unsafe context https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/unsafe-code - could the instability I'm seeing be related to some memory allocation issue associated with use of unsafe code? – mfisher214 Apr 13 '23 at 17:22
  • Did you check with WireShark or similar network tool just in case? – Christoph John Apr 13 '23 at 17:59

0 Answers0