I wanted to use API implementation
https://github.com/JKorf/Binance.Net which supports web sockets because I have many requests per a second and web sockets are kept alive through the entire uptime to avoid API limitations.
I don't know what's the standard way of adding that ASP.NET Core 3.0. I mean I could add it anywhere but it doesn't mean it's the right solution. Please note that I don't want my Web API to host web sockets but I want to connect to one and use the data it
provides.
using(var client = new BinanceSocketClient())
{
var successDepth = client.SubscribeToDepthStream("bnbbtc", (data) =>
{
// handle data
});
var successTrades = client.SubscribeToTradesStream("bnbbtc", (data) =>
{
// handle data
});
var successKline = client.SubscribeToKlineStream("bnbbtc", KlineInterval.OneMinute, (data) =>
{
// handle data
});
var successSymbol = client.SubscribeToSymbolTicker("bnbbtc", (data) =>
{
// handle data
});
var successSymbols = client.SubscribeToAllSymbolTicker((data) =>
{
// handle data
});
var successOrderBook = client.SubscribeToPartialBookDepthStream("bnbbtc", 10, (data) =>
{
// handle data
});
}
as you are subscribing to events, you just want to connect once, probably in startup. I'd probably start a new thread to run the subscription on so it does not affect request processing.
as you are subscribing to events, you just want to connect once, probably in startup. I'd probably start a new thread to run the subscription on so it does not affect request processing.
Like adding it in Configure (Startup.cs) and creating methods to return the result from the subscribed event in order to access the WebSocketClient object?
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
6 Points
32 Posts
Connect ASP.NET Core 3.0 to Web Sockets
Nov 11, 2019 06:26 AM|Hulkstance|LINK
I wanted to use API implementation https://github.com/JKorf/Binance.Net which supports web sockets because I have many requests per a second and web sockets are kept alive through the entire uptime to avoid API limitations.
I don't know what's the standard way of adding that ASP.NET Core 3.0. I mean I could add it anywhere but it doesn't mean it's the right solution. Please note that I don't want my Web API to host web sockets but I want to connect to one and use the data it provides.
All-Star
58144 Points
15646 Posts
Re: Connect ASP.NET Core 3.0 to Web Sockets
Nov 11, 2019 04:45 PM|bruce (sqlwork.com)|LINK
as you are subscribing to events, you just want to connect once, probably in startup. I'd probably start a new thread to run the subscription on so it does not affect request processing.
Member
6 Points
32 Posts
Re: Connect ASP.NET Core 3.0 to Web Sockets
Nov 14, 2019 10:48 PM|Hulkstance|LINK
Like adding it in Configure (Startup.cs) and creating methods to return the result from the subscribed event in order to access the WebSocketClient object?
Contributor
2690 Points
874 Posts
Re: Connect ASP.NET Core 3.0 to Web Sockets
Nov 27, 2019 08:24 AM|Rena Ni|LINK
Hi Hulkstance,
Did you make error in your project?
You could refer to the github as below:
#Web Sockets in ASP.NET Core
https://github.com/JKorf/Binance.Net/issues/252
Best Regards,
Rena