Spincel
Spincel

Reputation: 190

Using SignalR with a self-host WCF and consume the hub proxy through HTML client

So currently, I am working on migrate an old project that implemented WCF service and consume it through Silverlight client. This WCF service is using duplex polling method that Silverlight automatically understands and knows how to deal with it. Hence, a new HTML client will be replacing that Silverlight client.

After doing some research, I found some working solutions: using long polling web api or similar, adding support for WebSocket in the WCF through .NET WebSocket implementation, and using SignalR. So far, I am leaning more to SignalR due to the fact that I want to minimize the changes to the WCF as much as possible.

So if my understanding is correct, when using SignalR, it will create a Hub proxy that communicates between the service in the server and the client. Also, it will take care of the transport for the communication, in which it can use WebSocket by default and fall back to other protocols if WebSocket is not supported in the browser, and it can do so without the implementation of the protocol in the service.

My question is that if I want to use SignalR with my current WCF service, what would be the steps to make it work? The WCF service is a self-host that is running as Windows service on a server. Inside the WCF service, I have different end points for sub-services as well as the current end point to the Silverlight client. So far I was be able to add self host SignalR with the WCF service project and it is running, but I am not sure what would be the next step. Do I have to add a separate end point for the SignalR hub?

Another question is that do I need to make some modification to the duplex services to make it work with SignalR? Also, can the client project be separated from the SignalR within the WCF service project? And finally, compare between adding support for WebSocket within the WCF service and just implement SignalR, which one would have a better advantage in long term.

Thanks.

Upvotes: 1

Views: 166

Answers (1)

PriyaMukundan
PriyaMukundan

Reputation: 9

.Net 4.5 has introduced NetHttpbinding in WCF that uses websockets automatically for duplex message pattern and http for request reply message pattern.

More on Nethttpbinding here - https://msdn.microsoft.com/en-us/library/hh674273(v=vs.110).aspx

Upvotes: 1

Related Questions