epam / fix-antenna-net-core

FIX Antenna™ .NET Core is a high-performance low latency .NET FIX Engine.
https://www.b2bits.com/trading_solutions/fix_engines/fix_engine_net-core
Apache License 2.0
36 stars 15 forks source link

Disconnect / losing fix connection not in logs #101

Closed derMaaster closed 1 year ago

derMaaster commented 1 year ago

Hi,

I have a production application using the FixAntenna nuget package: NetCore 1.1.0. I make two fix session connections with identical settings. The one just a different port.

At random I lose connection with only one of the fix sessions, maybe 10min in, maybe 40min in.

No indication in the log files at /logs/<SenderCompID-TargetCompID.out/in.

fixEngine.properties:

Log.TraceIsOn = true Log.Engine.TraceIsOn = true Log.DebugIsOn = true Log.Engine.DebugIsOn = true Log.NoteIsOn = true Log.WarnIsOn = true Log.ErrorIsOn = true Log.FatalIsOn = true

tradePeriodTimeZone = GMT+2

inMemoryQueue=true validation=false queueThresholdSize = 1

enableNagle=false

validateCheckSum=false validateGarbledMessage=false

markIncomingMessageTime=true cpuAffinity=0

Is there another setting or location I can see more detailed connection specific logs to troubleshoot?

Viktar-Tserashchuk commented 1 year ago

Hi @derMaaster,

We use NLog to log FixAntenna operations. You could create an NLog config and put it in the folder with Antenna to receive more information about what is going on.

Here is an example of the config from our repo: https://github.com/epam/fix-antenna-net-core/blob/main/FixAntenna/NetCore/NLog.config It will log to the console.

Here is the NLog documentation you can use to configure logging into a file: https://github.com/nlog/NLog/wiki/File-target

derMaaster commented 1 year ago

Thanks @Viktar-Tserashchuk , please confirm - FixAntenna has NLog "built in" and that is its logging functionality, and when I put NLog.config into the same base folder as say fixengine.properties, that will overwrite the basic settings of FixAntenna's logging ? (if I am using the nuget package...)

derMaaster commented 1 year ago

When I move from the nuget packge to referencing Epam.FixAntenna.NetCore.csproj and change the NLog file there to:

`<?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<variable name="conLayout" value="[${date:format=yyyy-MM-dd HH\:mm\:ss.fff}] [${level:uppercase=true:padding=5}] [${threadname}] [${logger:shortName=true}]: ${message} ${exception:innerFormat=Message,StackTrace}"/>

<targets>
    <target name="logFile" xsi:type="File"
        layout="${conLayout}" 
        fileName="${basedir}/logs/logfile.txt" 
        keepFileOpen="true"
        encoding="utf-8" />
</targets>

<rules>
    <logger name="Ridd*" minlevel="Trace" maxlevel="Debug" writeTo="logFile" final="true" />
</rules>

`

I dont get different output in appl/logs/ ...

Tried NLog's simple example too:

`<?xml version="1.0" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<targets>
    <target name="file" xsi:type="File"
        layout="${longdate} ${logger} ${message}${exception:format=ToString}" 
        fileName="${basedir}/logs/logfile.txt" 
        keepFileOpen="true"
        encoding="utf-8" />
</targets>

<rules>
    <logger name="*" minlevel="Debug" writeTo="file" />
</rules>

`

Viktar-Tserashchuk commented 1 year ago

I would put nlog.config into the folder with your binary files. FixAntenna uses it only for the engine logs. .in/.out files are not affected by any changes in nlog.config.

Your config file will work if you surround it with proper tags:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

...

</nlog>

and change <logger name="Ridd*" to be <logger name="*"

Also, it's better to skip setting maxlevel="Debug" as it excludes the info level messages.

The full config that worked for me looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <variable name="conLayout" value="[${date:format=yyyy-MM-dd HH\:mm\:ss.fff}] [${level:uppercase=true:padding=5}] [${threadname}] [${logger:shortName=true}]: ${message} ${exception:innerFormat=Message,StackTrace}"/>

    <targets>
        <target name="logFile" xsi:type="File"
            layout="${conLayout}" 
            fileName="${basedir}/logs/logfile.txt" 
            keepFileOpen="true"
            encoding="utf-8" />
    </targets>

    <rules>
        <logger name="*" minlevel="Trace" writeTo="logFile" final="true" />
    </rules>

</nlog>
derMaaster commented 1 year ago

Thanks @Viktar-Tserashchuk

I did have proper tags, I just did not post those with the rest of the example - apologies for the confusion. Turns out I had the base directory wrong - the debug files were there, with the binaries.

Once again - I appreciate the support and help you guys provide.