After posting a question about the best way to call server methods from clients and clients method from server using C#, I'm trying to start using SignalR but I'm not familiar at all with the web programming.
I would like to use a Windows service as SignalR server and .NET Windows applications as clients. I saw in some other questions asked 1 year ago (like this console app example and this other one) that the best solution would be to use Owin self-host on the server-side, and a HubProxy in the client applications.
Is it still the best approach?
Thanks!
Related
My team is in the middle of deciding the architecture of our backend system:
Webserver A is an ASP.NET MVC application with ASP.NET Web API component, hosted in Azure Website.
Windows Service B is a self-hosted OWIN server that will periodically push notifications to clients who subscribes to the notification, hosted in Azure VM.
Windows Service C is a client that subscribes to notification from B, hosted in Azure VM.
Since we are more-or-less entrenched in .NET stack, we implemented B as SignalR server with C being the SignalR client. This part seems to work well.
Now comes a point where we also want A to subscribe to B, but I realize that it means an ASP.NET Web Server is going to act as SignalR CLIENT, instead of the typical scenario where it acts as SignalR server.
I presume we can initialize the SignalR connection in Global.asax and make the process ever-running to avoid AppDomain recycle. However, I feel a bit iffy when a Web Server is made to do something other than serving web requests. This solution also make the web server not stateless since it needs to maintain the web socket connection alive.
Is there something fundamentally wrong with making an ASP.NET application a SignalR client? Is there any possible gotcha with this setup?
In Azure you cannot tell that your AppDomain will not recycle. Because of many reasons, it can restart itself to heal and then you will end up making a new connection to the SingleR server. Is that OK for you?
Also SingleR is mostly used in the Web Functionality improvement where polling and refresh on web clients is made simple. But as your requirement seems to be all a back end stuff, I would suggest you to go with any other event driven pattern. Check Azure Service Bus topic/subscription model to have different components listen to various events and act accordingly.
I like SignalR and I am developing 2 things.
Server side code
Client web app
The challenge is that I need to allow the server to be implemented in a non .NET environments like may be Java or PHP. In that case the client will be using
"SignalR" libraries and server has to match the SignalR implementation on the server (in PHP, Java, etc). In a way, what I am after is shipping a server side API and a .NET signalr based implementation, but allow anyone to be able to implement the server side API in php/java etc
For this, what I need the API sequence and protocol signalR uses. I am kind of thinking that this is not going to happen because SignalR is matched on the client and server side to talk in specific way to make the magic possible.
Has anyone else been in this predicament? Any ideas on what the best way to proceed? By the way, before you ask the question, if it is a pure websockets based app, I will have less problems, I can just user WebSockets standard APIs.
However, I might need to fallback on long polling, because my server might need to run on Windows 7 - where websockets is not available.
Instead of reverse engineer the SignalR protocol make sure the clients do not have direct dependency on SignalR. Create client side adapters for the different server side framework. Include the correct adapter depending on server side platform
Here is a description of the SignalR protocol.
I have a use case where we will have an ASP.NET MVC Server Application but it needs to talk over a persistent connection to a Windows service. It doesn't look like SignalR does this as it really wants talk Server to JavaScript browsers but I did notice .NET desktop libraries. Can it talk from a server to a Windows server? If not, is there a recommended way, TCP/IP or HTTP to have a persistent connection between the two? NetTcpBinding in WCF?
Yes, there is a SignalR client library for .NET that you can use in any old .NET app to talk to a SignalR server just like you can from JavaScript.
While there is a WebSockets binding for WCF, there is no binding that actually talks native SignalR which adds its own message framing on top of raw web sockets. So, while possible, it doesn't exist today and I wouldn't hold my breath for it ever being created.
Why not simply have a queue using RabbitMQ. And anytime the web need to talk to window service, it push a message into the queue while the window service listen to the queue
Tools : VB.net (VS2010), MySQL
I've a client desltop application connecting to my asp.net (vb) website. The desktop app typically sends a request and web app (server) responds to it.
Now, for certain scenarios, I would like website to connect to the client app and sends some data. How do I do it ?
I know client-server app (desktop app to desktop app) but not sure whether this can be done from website to destop app.
Any help is appreciated. Thanks.
You could use SignalR Framework.
From asp.net website : "ASP.NET SignalR is a new library for ASP.NET developers that makes developing real-time web functionality easy. SignalR allows bi-directional communication between server and client. Servers can now push content to connected clients instantly as it becomes available. SignalR supports Web Sockets, and falls back to other compatible techniques for older browsers. SignalR includes APIs for connection management (for instance, connect and disconnect events), grouping connections, and authorization."
Have a look here for documentation and tutorials : http://www.asp.net/signalr
I want to create a socket on the client to listen for notifications from the server. Is there any example of a socket server built that I can use in my asp.net application?
Asp.net is state-less you would need to build a windows service or windows application to publish a socket end-point unless you are looking at something like Comet?
Asp.net cannot fire server events if there is no intervention by a process or a user.
Can you describe your requirement a bit better?
https://github.com/SignalR/SignalR is a Server side and client side implementation of Comet it looks like a suitable solution for messaging purposes what are you attempting to build this might give more insight to a suitable solution.