Closed Jiraiyah closed 5 years ago
Hello,
it is correct behavior, it is a "feature" of C# CancellationToken
.
The .NET websocket client assigns CancellationToken
to some async method and when we call close, it throws this exception and terminates everything.
One mistake is, that it is catched by our logger, this excetion should be swallowed. @Jiraiyah could you provide that private repo? I will implement some better error handling.
I have a hunch that these 4 streams are the trade bin streams i have (1m, 5m, 1h, 1d). Why do i say that?
I have the main presenter in a dll library but then, in the form app i inherit a class from it to listen to these streams because the candle library i use (trady) is out side of the base dll so i need to inherit from the other presenter.
This inherited one is the one i instantiate in the app and use. looks like for some reason, although i am disposing everything in the inherited class, these 4 streams are not getting closed properly before disposing of the client. looking into what is available in client, i don't see anything related to streams to manually dispose or stop listening so i assumed it would automatically get disposed when you dispose the client. for some reason, these 4 streams that i add in the inherited class, are not doing it !
no worries. let me set it up and i will give you heads up for access
@Marfusios The repo is ready, give me the id of bitbucket and i'll give access to you
You can find me there by my email m@mkotas.cz or https://bitbucket.org/m4r10/
here we go sir :
the base class >> https://bitbucket.org/TraderSet/tradersetbot/src/cf27889bfefd52796fa0b5dc88ba6bc54bc4411a/Bitmex.Web.API/StatsPresenter.cs#lines-350
the inherited one >> https://bitbucket.org/TraderSet/tradersetbot/src/cf27889bfefd52796fa0b5dc88ba6bc54bc4411a/BitmexBot/Utils/CandlePresenter.cs#lines-168
https://bitbucket.org/TraderSet/tradersetbot/issues/1/cant-compile
Closing as we moved to BitBucket.
@Marfusios Hi I'm making a winform app and on closing event i call OnStop?.Invoke , which will effectively try to dispose the client. But on log file I get this :
2019-03-20 11:22:59.639 +03:30 [DBG] [WEBSOCKET CLIENT] Disposing.. 2019-03-20 11:22:59.641 +03:30 [ERR] [WEBSOCKET CLIENT] Error while listening to websocket stream System.OperationCanceledException: The operation was canceled. at System.Threading.CancellationToken.ThrowOperationCanceledException() at System.Net.WebSockets.WebSocketConnectionStream.d21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Net.WebSockets.WebSocketBase.WebSocketOperation.d 19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Net.WebSockets.WebSocketBase.d45.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Websocket.Client.WebsocketClient.d 61.MoveNext()
After the client is disposed some STREAMS still are trying to listen?
If you need to i can upload the project in a private repo on bitbucket and give you access to look into the problem