-
-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why socket message processed so long? #1127
Comments
Thanks for answer. I will test BinanceAPI for socket soon. Can u help me with other issue(#1145 ) with Ticker socket ? |
@vaniakurd, the data handlers are synchronous, i.e. you code inside the data handler @JKorf used In plain English, you should be off-loading the data handlers and process the messages in a separate context (thread). In your case you're causing backpressure. Backpressure is when the websocket produces more messages than you could handle (consume). Think about it for a second, the websocket produces 1 message per second and your data handler takes 5 seconds to execute. Your consumer is always going to be late. If you run your application for a day, you'll end up working with old data. This is usually solved by the pull-based or push-based programming model. Refer to: https://www.infoq.com/articles/Async-Streams/. client
.Streams
.TradesStream
.ObserveOn(TaskPoolScheduler.Default)
.Subscribe(trade => { code1 }); |
@Hulkstance, Maybe i don't understand something, but even if i write code with empty dataHendler i will see the same situation. This code from CryptoExchange.Net:
I dont understand what work so slow, with emty dataHandler |
Sokcet options: LogLevel = Microsoft.Extensions.Logging.LogLevel.Trace
i just wanna ask about message processed. I not sure but it seems to me that 3 ms for parse response is a lot. This logs from VS outpoot window.
logs.txt
The text was updated successfully, but these errors were encountered: