I need a ClientWebSocket wrapper in order to connect and collect data from wss://stream.binance.com:9443. The received data should be broadcasted to the UI (realtime UI) through a web socket server.
The broadcast part can be achieved using SignalR .NET Server. It is documented on MSDN.
The client web socket part is what I can't imagine. I found a SignalR .NET Client that I can use to connect to wss://stream.binance.com:9443, however I don't think it is possible, because SignalR probably has its own transport protocol. Is it correct?
If the Signal .NET Client doesn't work in my case, could you please direct me to alternative solutions? I was looking at the following
https://github.com/Marfusios/websocket-client
https://github.com/skunklab/piraeus/tree/96fcbc854d0c8d2c2cd62e457f06ef638859b6eb/src/SkunkLab.Channels/WebSocket
https://gist.github.com/xamlmonkey/4737291
It's worth stating that the ClientWebSocket subscriptions to Binance will be created for multiple API keys (unknown amount of users - based on DB user records).
Related
I want to host a WebSocket stream API, mostly for financial data, such as Deribit JSON RPC API over websocket and Binance WebSocket Stream API. I don't want to bother with SignalR because there is no SignalR client support for most of the languages.
Requirements:
The hosted endpoint should be using the WebSocket protocol, i.e. wss://...
Rate limitting capabilities such as Binance's. Speaking of it, they added Sliding Window Rate Limiting in .NET 7 (link). I also found another solution using Redis (Redis Sliding Window Rate Limiting).
If you take a look at the Binance WebSocket Stream API, you'll see that you're able to subscribe/unsubscribe to a stream which makes me think that they are using some kind of a PubSub system over WebSockets.
I did some research and found Azure Web PubSub as a solution (use case here) which is using WebSockets and it is intended for non Azure clients (non SignalR clients).
I couldn't find any websocket server frameworks for ASP.NET Core, so here is the question. What do you guys recommend in this case? Not sure if I could achieve the same using RabbitMQ or Kafka.
I am running an ASP.Net Web Forms application in an Azure Cloud. Now I have a special requirement that I have no idea how to solve: the server has to accept incoming connections over the internet from Android clients and then keep that connection open (or on standby) for a long period of time (days). So after hours or even days, the server has to find it's way to the Android client and send some data to it. I can use whatever technology works for both partners, but since the internet is in between, http/https is prefered as protocol (although WCF with TCP endpoints might also work when the connection is initiated by the client). The only thing I can think of is having the clients constantly poll the server if there is a command/data available, but that solution is ugly and wastes a lot of ressources. The client should react within seconds when the server has something to do for it, so I'd have to use a polling interval of ~10s. I know that http "keep alive" exists and can be utilizied in C# WebClients, but I doubt that it will work with my requirements? Is there any other possibility to achieve this?
Based on Niraj's response, I found Google Firebase Cloud Messaging. After that, I read up on the XMPP protocol and the SignalR technology available for .Net and finally decided to go with SignalR as it's implementation is most simple and does not require involvement of a 3rd party.
I am recently learning about web sockets in .Net and have just found SignalR which seems like too good to be true in terms of the abstraction of what connection to use and it seems like there are a few signalr clients in different languages which is awesome.
In my current project different resources are being exposed through a RESTful API, and from my understanding of websockets the client needs to upgrade to a web socket connection through a HTTP request/response. Does signalR handle all this handshaking going on?
If there is an initial request/response from a GET request to retrieve a certain resource but they opt to upgrade to a socket connection, does the server give them any sort of response besides the response saying it acknowledges to open up a web socket connection or is the handshake all that occurs before the information is live updated for that particular resource?
Do you think signalR is scalable as opposed to implementing this through a protocol like STOMP where there are a large number of client libraries?
You are making things too complicated. A typical example of using signalr is:
an html file using JavaScript to connect to a signalr Server when the page is loaded. we call this signalr client.
a signalr server written in c#. it can be a winform or console or service.
the signalr Server can call any dll, or webservices or webapi located in the same server, or even in different Server.
then, the client can call any function defined in the signalr server. the server can call any function defined in the client for a particular client or for groups of clients.
also, client x can call client y functions as well.
you can actually forget about Web sockets, signalr choose the most appropriate transport protocol for you. it will choose Web sockets if it is available in both the server and the client.
I am thinking about using SignalR in some WCF and WPF applications.
In reading about SignalR I understand it supports 4 different transport types:
WebSocket
Server Sent Events
Forever Frame
Ajax Long Polling
If I have a WPF or WCF application using the SignalR .net client talking to a normal SignalR server (like the SignalR sample), which one of these transport types are used?
The SignalR .NET client supports up to 3 transports:
WebSockets (.NET 4.5 only)
Version 2.2.0 of the SignalR client will also support the WebSocket transport in universal Windows apps.
Server-sent events
Long polling
There is also the default auto transport that will try to use the best transport available. For example, it will initially try to start a connection using WebSockets, but if that fails, the it will try to use server-sent events next and then long polling.
The .NET client will never try to use the forever frame transport because that transport is very similar to server-sent events. The main difference between the two transports is that the forever frame transport wraps its payload in HTML to support older browsers which load the payload using an iframe.
You can learn more about the .NET client and the provided transports in this guide.
We want to implement a client server application. here is the scenario.
Server listens for client 24/7.
Server accept request for client and save it in DB for further process.
Once processing is done (it may take few hours), Server will response back to client.
in short , client and server listens for each other 24/7.
I want to implement it in C# but i also want that it should be accessibly from all platforms.
Also is it possible in WCF?
I agree with Yuck, this is a basic WCF scenario. There a few articles, videos and tutorials to get you started here http://msdn.microsoft.com/en-us/netframework/dd939784