how to redirect SignalR Request to another Machine - wcf

I have many clients connected to a server in SignalR
but I want the server to redirect or route all of the Requests to another server , and to route the response to the clients in the same way used in WCF routing service so how can we do this on SignalR ,please ?
To be more specific
I have a server with a web app published on internet
some of the clients Devices cannot connect to the internet
I need to connect them to the server via an intermediate machine connected to the internet.
The client can connect to this machine and the machine connect to the internet then to the main server.
I used WCF routing services to do it for WCF
but what is the technique for SignalR ?
thanks

You can make each of your SignalR machines individually addressable and then have a single machine manage which clients should connect to which SignalR servers.
Each client could make an Ajax request to the management machine which could then respond with the URL the client should establish a SignalR connection to.
If you need clients on separate machines to be able to communicate with each other using SignalR, you should look into SignalR's scaleout providers: http://www.asp.net/signalr/overview/signalr-20/performance-and-scaling/scaleout-in-signalr
As indicated by the first diagram in the previous link, you can put your SignalR servers behind a dumb load balancer if you decide to use a scaleout backplane.

Related

Adding Application Insights to a WCF service on a locked down IIS box

We have a server in our DMZ that we use to host our WCF web services on for some external clients.
This server only accepts connections from a single IP address to make it more secure.
Does anyone know if this it is possible to add application insights to a service that only accepts connections from a single IP? would I need to make changes to allow application insights to work?
Thanks
Martin.
Application Insights collects telemetry and sends it out to back-end servers hosted in Azure. So, till you have outbound connectivity to Azure, your web services will work fine with Application Insights.

Request/response messaging pattern - Azure Service Bus

All ,
I have a doubt on the Request response pattern... Assume the following is my scenario
1.I have a service running on Windows Azure. This service can be called by users to execute a command.
2.I have a client applications that is running on my intranet. This client application will execute the command . The computer in which the client application is running is connected to internet , but does not have a static IP i.e machine cannot be accessed directly via the internet
3.I am planning to use Azure Service Bus through which my service on Windows Azure can communicate with the client application to execute....
In this scenario, can i use Request/response messaging i.e can the service post a message and expect a response from the client
OR
Should i use command queue for each client , the Service will push the command to be executed on a queue , the client will poll the queue and execute a command
Any help is appreciated
Since you are using WCF (based on the tag), you should consider using Service Bus Relay calling the WCF service asynchronously.
I assume you want to use Relaybinding here, using WCF.
Your web service (which is behind NAT, firewall devices, etc) is only opening outbound connections in that case. The service is listening on a registered endpoint in the cloud (that is accessible for him, because of credentials and protocol). All incoming service calls are sent over that port/socket. The response will then be sent back over the outgoing port again.
If the IP Address of your service changes, it wil register itself again (by listening on the same registered endpoint) and you can reach that service transparantly.
Another way you can achieve request/response in an asynchronous fashion, is through queues. This does not require any open connection between your client and your service and can happen fully asynchronous. This can be achieved by sending a message to the request queue for your specific service (with a Correlation Id). And when that service has processed that message, it can send the response to the response queue of your application, using sessions. A good example of this pattern can be found on Alan Smith's blog: http://www.cloudcasts.net/devguide/Default.aspx?id=13051

Calling a net.tcp wcf service from Silverlight - in an external facing web site?

I have an external (public) website developed in Silverlight. The Silverlight app currently calls http based wcf services hosted in IIS.
I am now having to call a wcf service with net.tcp binding hosted in a different app server. I have the net.tcp wcf service hosted in a windows service on port range 4502-4530 and with an interface to expose clientaccesspolicy.xml file as part of the service. I am able to invoke this service from my Silverlight app in the web server. I want the SL app to make direct call to net.tcp, rather than routing the call to it from another http based service.
Question is will this work without any issues when exposed over internet.
Client browser --> IIS webserver with Silverlight website --> App Server with wcf service on net.tcp.
I am assuming in this case, from XAP SL would try to make direct call to the app server service using net.tcp ?
The communication between the web server and app server could be opened up for ports 4502-4535. But I am wondering what about the client. Does this setup require the ports to be available even in the clients machine (with browser)?
Any insight is much helpful.
Thanks.
Take a look at http://support.microsoft.com/kb/2425652; there is sample code included as well! If you setup clientaccesspolicy.xml correctly; it should work as long as clients can access your TCP server.
If your clients are behind some firewall which is blocking your server's ports; they may face connectivity issues!

SignalR - Sending a Message from a WCF Project

I've followed the instructions from https://github.com/SignalR/SignalR/wiki/Hubs
entitled "Broadcasting over a Hub from outside of a Hub".
I got this method working from within an MVC Action in the same project. Requesting the Action sends the update to connected clients.
My problem is that I need to be able to send updates from another project, in particular a WCF Web Services project. My app has an API and a web component and when API users make calls that change things, these updates need to be pushed out to the Web clients via SignalR. And calling a web service with the same code as my Test Action doesn't work.
I also tried the same code inside an nunit unit test that didn't work either.
What do I need to do to make this same method described on the Wiki work for a WCF Project?
The easiest solution is probably to provide an API on your Web Application (use MVC or the new WebAPI) that broadcasts to all connected clients. Any other application (an NT Service, an NUnit test, ...) can call that API if it wants to send a message to the clients.
You can't expect SignalR to do anything if you aren't hosting a Hub either in a Web Application running under IIS, or another application hosting it directly.
If you need two-way communication from your separate application to your clients then simply make your application into a SignalR client too and have it communicate via the Web Application hosted SignalR to the clients and have it listen to messages from them too.
For example, here's how I have configured a complex Service + WebSite + Clients solution (ignore the purple for now):
The Live Web Server allows NT Services to connect and create SignalR Groups. NT Services send to those groups. Web browsers connect to a group and receive messages send to that group. In effect the middle box becomes a pubsubhub.
I cannot get exactly what you aim. But if I understood correctly you're trying to send some kind of notifications raised inside WCF services to SignalR clients.
If that's the case; I can suggest you my approach:
I have some WCF services and a SignalR hub in the same application server. IMHO, the best way to communicate WCF with SignalR hub is by using MSMQ.
When a notification occurs inside a WCF service, it puts the notification payload into MSMQ.
On the other end, SignalR hub listens the same queue. When a message put into the queue, it gets the content and broadcasts to the hub clients. Very easy and straightforward. No extra service/hub call at the server side.
SignalR hub can listen for new queue items by using System.Messaging.MessageQueue#ReceiveCompleted method. When this event raised, SignalR hub gets the queue item and broadcasts to its clients.

wcf session authentication

I'm currently building a game that uses a client/server model. I'd like the server side to be a WCF service. The client will be silverlight or flash. What need to solve is session authentication. A user needs to log into the game, be authenticated via the service and hopefully establish a "session." I need to make sure that you can't send commands to the server without being authenticated. Authentication on the server side will be tied to a SQL database. I should also mention that it needs to be a duplex connection.
Related to this question, what about load balancing? If the service runs on multiple machines and is load balanced with the NLB service and I store those connection references, how would I get a reference to a client connected to a different machine in the same cluster?