Using SignalR as client side API scheduler - c#

I have seen lot of examples of using signalR in combination with API as push notification events for client to notify of updated data available. Is it possible to use SignalR as an client application that schedules REST API Calls in the case the server doesn't have any signalR service. Here is what I am trying to do. I am client that uses API provided by vendor to make calls to pull data and map it to our database. There is no way of knowing that there is new data until I make a REST API call to check.
This is where I am thinking that the long poling feature of signalR would come in handy. Idea is to create a local executable application that uses SignalR to call the api to check if there is new data and then execute a service (another .net executable application) that will pull the data and consume it (map it to our database).
Can this work?

Related

Communication Windows Service / Web Server

We have a current application that has consists of two solutions:
Windows Service
This one takes care of communication between devices (ie. IoT, and other devices through different communication protocols); this service also contains some logic and runs 24/7; writes ocassionally to a database (SQL or Influx).
Web Interface
The web interface shows some of the database information; but can also get information from the Windows Service (live data); we currently use RabbitMQ with RPC for this; but it is far from ideal. We use Typescript to call back to a controller; from the controller we RPC to the Windows Server and the way back again.
We are currently looking on how to evolve this to a more robust solution with less transfer objects in between while maintaining security as the web interface has login credentials.
Ideally we would replace all with SignalR as this would make the client side also easier; we have a lot of TypeScript currently to do Rx calls.
My particular concern would be security in having SignalR directly to the Windows Service.

Are WCF + Callbacks suitable for sending commands to the client?

I'm trying to create a WCF service for our existing product.
The service should provide normal "webservice" features (one-way), but also act independently.
Sample scenario:
The client connects to the server
The server saves the client in a collection
Now I use an admin client / database entry to tell the client to do sth. (For example change config for log4net/NHibernate)
I've read some things about callbacks (mostly a chat system), but I'm still not sure if this will work.
Now my question is, will WCF be suitable for such a scenario or should I use TCPClient/TCPListener?

Send notification to web client from external service via SignalR hub hosted in Asp.Net MVC Application

Scenario is as follow : We have a Asp.Net MVC 4 App having a private messaging system that hosts a signalR hub used to notify users when new message are available for them. Everything works fine, the Web App register connectionId along with their username and the signal is sent to the hub from the DataLayer via a notificationAdapter class.
The problem came when we had to create a separate service leveraging Quartz.Net that also send private messages when tasks are finished. We want the Quartz service to be able to contact the Hub but we can't cause it is in a separate process. I don't want to use the signalR .net client because I don't need a permanent connection between the Quartz based service and my Web App. I think of creating an endpoint in my WebSite to expose Hub's server method to the service or to use ScaleOut for that but I feel like I miss something and though I would ask the community.
This might be a very late answer but seeing as there were no actual accepted answer. I'll provide one.
The easiest way to have your Quartz.NET application send information to your ASP.NET Web Application without implementing a heavy solution such as Enterprise Service Bus (ESB) is to simply expose a web service in ASP.NET and have your Quartz.NET call the ASP.NET web service when its task is finished. Once you're in your ASP.NET web service you should be able to a notification back to send a notification to the client through signalR.
I would have used Quartz Listener (Job or trigger listener) in the WebAPI, which then talks to the Hub.
Of course, use a shared ADO store between Quartz client (web API) and server (windows service).

C# Traditional Server with WCF Web Service

I am creating a client application that downloads and displays market data from Yahoo! for a university project, but that also sends out notifications to mobiles (so far using Google cloud messaging). So far it's a WPF client and the "server" is a class library - so far working. What I was wondering, is can you mix this server with a WCF service - the WCF service I was planning on using for registering devices, as well as accepting and parsing commands.
So I would call .Start() on my server object, and it will be constantly running in the background, while a WCF REST service runs alongside it - or would I be better simply having a thread running on the server that can accept input... sorry if this is confusing, but just wondering if it can, or has been done before or any advice. :)
Just to explain a bit better
The client front end and the "server" are running on the same machine - I was calling it a server because it is not only updating the front end, but sending out GCM notifications at the same time. I was wondering if maybe a WCF service could be added to make it simpler to handle adding devices to a database ("server" reads a list of device reg ids from a database, sends notifications to these) by allowing an android app to details via REST or something similiar
I would explore wrapping the class library in a Windows Service (which is essentially a process that runs continuously, and can be stopped/started/paused) and keep your WCF service as a web service for client communication.
How the WCF client service communicates with the Windows service is up to you - whether you store the data in a shared database, keep it in memory and have another WCF layer communicating between the two, etc. A shared database would be the most straightforward, especially if you want to persist the data for use by other apps/services as well.
WCF Service would be useful if you had one notification service on your server with multiple WPF client application connecting to it. If you have just one application running on the same server then not sure if it will be worth the overhead.
The usual pattern is to host WCF service in IIS, that way it always starts whenever first request is received. WCF is very flexible though, therefore you can host in in Windows Service, Console Application, etc.

Signalr on Azure: service bus required for calling a single client?

I read that Signalr on Azure requires a service bus implementation (e.g. https://github.com/SignalR/SignalR/wiki/Azure-service-bus) for scalability purpose.
However, my server only makes callbacks to a single client (the caller):
// Invoke a method on the calling client
Caller.addMessage(data);
If don't need Signalr's broadcasting functionality, is an underlaying service bus still necessary?
The Service Bus dependency is not something specific to Azure. Any time you have multiple servers in play, some of your signalR clients will have created their connection to a specific server. If you want to keep multiple servers in sync something needs to handle the server to server real time communication. The pub-sub model of service bus lines up with this requirement quite well.
dfowleR lists a specific case of this in the comments. Make sure you read down that far!
If you are running on a single server (without the sla on Azure) signalR will work just fine on a Cloud Service Web Role as well as the new Azure Web Sites. I did a screencast on this simple scenario that does not take on a service bus dependency, but only runs on a single server.
In order to support the load balance scenario, is it possible to enstablish a "server to server" SignalR PersistConnection between multiple instances (ie on Azure) ?
If so, we can use a SQL Azure Table where all instances register at startup, so newest can connect to previous ones.

Categories