Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push data to client using SignalR vs WCF?

I have one WPF client-server application. Now I have scenario like client will connect to server and server will push data to client periodically. I am bit confused about what technology and way should I choose for notification to clients.

SignalR is best for web application I think and I have desktop application. With WCF service, we can implement push notification through Duplex channel and callback. So can you please guide me what are the merits and demerits in using SignalR or WCF service ?

Thanks

like image 984
Upendra Chaudhari Avatar asked Mar 07 '13 09:03

Upendra Chaudhari


People also ask

Which SignalR allows bidirectional communication between server and client?

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.

Why do we use SignalR?

SignalR can be used to add any sort of "real-time" web functionality to your ASP.NET application. While chat is often used as an example, you can do a whole lot more. Any time a user refreshes a web page to see new data, or the page implements long polling to retrieve new data, it is a candidate for using SignalR.

Does SignalR use HTTP?

SignalR uses Web Sockets and the HTML5 API that helps in bidirectional communication. It also provides an API for server-to-client Remote Procedure Calls (RPC) call, it may be something new for you because most of the time we use a request and response model.

What is SignalR client?

SignalR is a free and open-source software library for Microsoft ASP.NET that allows server code to send asynchronous notifications to client-side web applications. The library includes server-side and client-side JavaScript components.


2 Answers

Below are my observations from experiences:

SignalR pros:

  • Easy to startup, lower learning curve. You can easily run an example found from web
  • Exception handling (e.g. connection drops, timeouts) is embedded inside the API

SignalR cons:

  • Only supporting HTTP protocol

Duplex pros:

  • Supports TCP in addition to HTTP. This may be a serious performance gain if you know your client types and your system is working in a closed network. Also, working over TCP adds more connection stability than HTTP

Duplex cons:

  • Higher learning curve - harder to startup and have a stable solution. Want to verify it? Download a duplex and a SignalR sample from the web and see how much time you will spend to successfully run each other.
  • You need to handle all the exceptional cases (connection drops, timeouts, etc.)
  • I know I am not the only one who faced serious timeout problems when you want to use the duplex service for a long time. We need to make service calls periodically to keep client connections alive.

By the way, there are APIs exist for JavaScript, Desktop and Silverlight projects to consume SignalR services.

like image 77
Hasan Avatar answered Sep 27 '22 18:09

Hasan


SignalR is not just about web. SignalR server side code does not care about the technology of its clients, you just need to have implementors at the client side.

If we isolate pusing data to the client, I would strongly recommend SignalR as it's much simpler than WCF in this aspect, I had my share of problems with WCF and I guess you had some yourself. I found a simple console/web application sample here.

In general, Duplex WCF and using Callback like here seems very messy to me, there is a lot of configuration server side and this is why I think SignalR is simpler.

In addition, you can't use duplex (AFAIK) with javascript and objective-c.

like image 40
Mithir Avatar answered Sep 27 '22 20:09

Mithir