Skip to content

Commit

Permalink
Merge pull request connamara#835 from gbirchmeier/pr834-Falcz-OnStart…
Browse files Browse the repository at this point in the history
…-patch

Add Try/Catch logic to SocketInitiator.OnStart()
  • Loading branch information
gbirchmeier authored Feb 13, 2024
2 parents e97b24a + db27ba3 commit 6bdc40b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 14 additions & 5 deletions QuickFIXn/Transport/SocketInitiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public static void SocketInitiatorThreadStart(object socketInitiatorThread)
// so we resort to storing it in a local file.
try
{
// TODO: temporary hack, need to implement a session-independent log
File.AppendAllText("DisposedSessionEvents.log", $"{DateTime.Now:G}: {exceptionEvent}{Environment.NewLine}");
}
catch (IOException)
Expand Down Expand Up @@ -196,13 +197,21 @@ protected override void OnStart()

while(!_shutdownRequested)
{
double reconnectIntervalAsMilliseconds = 1000 * _reconnectInterval;
DateTime nowDt = DateTime.UtcNow;
try
{
double reconnectIntervalAsMilliseconds = 1000 * _reconnectInterval;
DateTime nowDt = DateTime.UtcNow;

if ((nowDt.Subtract(_lastConnectTimeDt).TotalMilliseconds) >= reconnectIntervalAsMilliseconds)
if ((nowDt.Subtract(_lastConnectTimeDt).TotalMilliseconds) >= reconnectIntervalAsMilliseconds)
{
Connect();
_lastConnectTimeDt = nowDt;
}
}
catch (Exception e)
{
Connect();
_lastConnectTimeDt = nowDt;
// TODO: temporary hack, need to implement a session-independent log
File.AppendAllText("SocketInitiator-OnStart-Failure.log", $"{DateTime.Now:G}: {e}{Environment.NewLine}");
}

Thread.Sleep(1 * 1000);
Expand Down
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ What's New
* #786 - rewrite HttpServer: better HTML, no crash on errors (gbirchmeier)
* #697 - new SocketIgnoreProxy setting (ABSJ415)
* #740 - Capture inner exception messages when handling authentication exceptions (rars)
* #833 - Add Try/Catch logic to SocketInitiator.OnStart() (Falcz)

### v1.11.2:
* same as v1.11.1, but I fixed the readme in the pushed nuget packages
Expand Down

0 comments on commit 6bdc40b

Please sign in to comment.