Clean stopping of continuous connectivity to RTO

We are in the process of making changes in order to shut down our connection to the rate feed just prior to our end of day process begins….and then to reconnect hours later in the early morning. The developer has come upon some errors when attempting to reconnect to the feed and I am hoping you can provide some guidance. We are very interested in making sure that we are performing this disconnect/reconnect in as per Refinitiv’s standards. These changes are meant to quiet some of the after-hours connection errors we receive here on a regular basis.

Also say we are reconnecting after a time period. There examples show exiting after disposing of the WebSocket Task. This results in a TaskCanceledException the next time I try to connect. I am currently ignoring this error but would like to know if there is a better way.


e.g. Code to cancel the socket.

Cts.Cancel();

WebSocket.Dispose();

This is the exception I get:

canceled.

--- End of inner exception stack trace ---

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)

at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)

at System.Threading.Tasks.Task.Wait()

at BusinessService.RefinitivFeedMgr.SendMessage(String jsonMsg, Boolean logMe) in D:\Users\lauxt\git_branches\ABC_11.0.200.0\Business\BusinessService\Impl\ScheduledTasks\RefinitivFeedMgr.cs:line 794

at BusinessService.RefinitivFeedMgr.SendLogin(Boolean isRefresh) in D:\Users\lauxt\git_branches\ABC_11.0.200.0\Business\BusinessService\Impl\ScheduledTasks\RefinitivFeedMgr.cs:line 778

at BusinessService.RefinitivFeedMgr.Connect() in D:\Users\lauxt\git_branches\ABC_11.0.200.0\Business\BusinessService\Impl\ScheduledTasks\RefinitivFeedMgr.cs:line 678

---> (Inner Exception #0) System.Threading.Tasks.TaskCanceledException: A task was canceled.<---


Would you be available to assist

Best Answer

  • Hi @shawn.kelley

    Have you tried checking the 'IsCancellationRequest' or 'CanBeCanceled' properties before executing the Cancel()? The issue seems to be related to the state of your CancellationToken as opposed to being related to RTO.