I have my software(.NET) running on clients. I need to push the updates to the clients whenever available.
I thought to implement a web service which is running on the main server which broadcasts the update notifications to the client. For dat, CLient has to register their identity over the web to the server.
Server will send the notification on availability of the update. Client has to download the update from the server.
Will WCF would be the good option? .. Is that possible to implement? .. I know there are so many constraints in the networked environment. Suggestions are welcome...
You can make a table for application details including version and in application loading check the version of the application against last version number in database via a webservice if the versions are different fire error method to notify the client there is a new version of his application
but that I think valid from the start but you says the application is already running so I think you have to add this feature to the application and reinstall it on client machine.
check the following posts it may help you to find what you looking for
http://www.installsite.org/cgi-bin/frames.cgi?url=http://www.installsite.org/pages/en/tt_patch.htm
Is there a standard way for .NET Winforms apps to auto-upgrade?
http://www.devx.com/dotnet/Article/10045/1763
http://www.codeproject.com/KB/install/DDayUpdate_Part1.aspx
Maybe "long polling" is a solution. Consider this scenario: Your clients connect to a server using a timeout of lets say 60 minutes. If your server has an update it sends the data and closes the connection causing your client to reconnect and wait for the next update.
Wikipedia: Comet (Programming)
Since you provided details regarding infrastructure and communications I'll go with long polling again. Here is an example (first hit for "WCF long polling" on Google):
Simple Long Polling in WCF - Server
Write a windows service which runs on the clients and periodically checks the update server for new version of your software.
Related
I have an application in WPF c# which will run on client machine. Another application (maybe some kind of service) on a particular server will be running all the time and will wait for any incoming message from the client app. As soon as the server receives a request from any of the client application, it triggers a command line process and also responds to the client about the staring info(whether it was successful or not) and as well as when the command line process is finished it again responds to the calling client application that it got finished.
I am new to in this area.
So my question is should I use normal windows service or Web service or WCF?(Some kind of link to a demo project will really help). Any other suggestion are also welcomed.
You did not mention if your clients will be outside of your firewall or with in the same intranet. We have intranet scenario, and we use WCF service that communicates with WPF based applications over the internal network. WCF provides Duplex feature which enables two-way client server communication using an easy to implement programming model. I recently wrote an article on this and it can give you a head start for the WCF way.
However, WCF does not have the best support for callbacks over the internet and you may have to look in to effectively using it in your case. But if it is intranet, then my suggestion is surely to go for the WCF way. Hope it helps.
Background
I have multiple servers that I currently connect to remotely to run a number of different commands/scripts to obtain information about the servers and/or applications running on the servers.
I'd like to automate running the commands/scripts (or the code contained in the scripts converted to C#/.NET) and have the server send alerts/notifications/messages to a client (basically a Windows Form) running on multiple workstations, but need some guidance.
For reference, I have limited experience creating Windows Services, but feel fairly confident in being able to create them on the server to handle to command/script automation, which I'm assuming would be the best way to go about handling the command/script automation on the server (since the commands/scripts would need to be run all the time or at set intervals).
Question
How can I connect multiple servers to multiple clients so that the server sends alerts/notifications/messages to the client when a command/script or even an event occurs on the server?
For instance, if an application on the server has a built-in command that can be run to determine the status of the application (up, down, limbo, etc.), I would like the Windows Form on the client to receive an alert from the server when the command returns "down" or "limbo" when it is run, presumably from a Windows Service. The alerts would be displayed on the Windows Form that would be setup basically as a dashboard for the servers that the client can connect to.
An even better outcome would be that the client runs as a background application and a notification appears similar to how Microsoft Outlook displays a notification when new email messages arrive (although these notifications would likely require user interaction to close instead of fading out like the Outlook notifications).
I would also like for the client to use a configuration file that has the connection information for the servers in it so that the servers being used can be changed quickly new servers are added or existing servers are decommissioned.
Research (so far)
I've read about WCF and duplex contracts, and how WCF can be hosted in Windows Services. From what I've read, this seems promising. However, I'm not quite sure how I would set this up so that the client can connect to a WCF service on multiple servers.
One thing that I'm concerned about with WCF is that in all of the WCF examples (which implement a calculator-type service) I've seen the client has to initiate the communication with the server in order to receive a message through a callback. In the calculator service examples, the client sends numbers to the service and the result is provided in the callback. I've also seen an asynchronous example, but in that example the client initiated a single, long running request and the callback returned a single response when it was finished processing.
And, just so I'm clear about bindings in WCF, it is possible to create and use bindings for multiple servers using a configuration file without having to use SvcUtil.exe to generate the code, correct? The reason I ask is because the servers that will be configured will likely be change for different users, so the client needs to be flexible when connecting to the services.
I've just now started looking at Sockets, but I'm not familiar enough with them to know if this would be the better option to achieve my objective.
Summary
I'm just looking for guidance, so if you can help direct me to some resources that will help me achieve my objective, I would appreciate it. I've searched extensively, but the majority of my searching either doesn't apply to my scenario, it is limited to a single server/client interaction, or it is limited to a single server with multiple clients.
Since I'm not sure what direction to go in, I don't have any code examples, although I have implemented the examples in the following Microsoft article: Windows Communication Foundation - Getting Started Tutorial
So you want to build a system of
multiple servers which execute commands on the computer they are running on
multiple clients which will receive the status of the commands executed on server or such information from the server
This would be my advice
Servers can be implemented as windows service. You will be able to administrate them easily this way using the services console or the scm. Checkout this link for a creating a simple C# service How do you write and use a Windows Service in C#?
Also, you can set the service to run as an in-built service user with different levels of permissions in addition to regular user accounts.
I have not used WCF, but usually clients connect to the server; this is a pretty common model, and hence all samples are such. Initiating connection from server is not a big deal (at least in a socket program), but just a bad model. You have to ask yourself, if no client is connected to your servers, how can they relay a status to the end user. You have to think clearly about the communication model. I would suggest a central repository of messages. It can be a file on a shared file system or a database or any such entity which can act as a data repository. This way all servers can convey there messages without caring if a client is connected or not. You can use Sockets to achieve what you want to do. Check the asychronous socket server sample from MSDN to understand how to do it.
Making the client run in the background and just have a notification area icon is also easy in c#. You can use NotifyIcon Class for that. This CodeProject article (Formless System Tray Application) demonstrates its usage. To show notification a la outlook style, you can refer to the following post: How to create form popup from from system tray on windows application (not web) with c#. Look at not only the accepted answer but other answers too; there are lot of useful links in it.
So far we have windows service talking over sockets, storing messages in a central repository and capable of handling multiple clients with toast style pops for client side notification.
You need a far richer client side GUI so the end users can take actions on the messages sent from the server. You can maintain a list of servers in app.config for the client that the client connects on startup. You should to provide a GUI for users to manage all servers and their connections.
Lat but not least, by building such a client server model, you are effectively building a security loophole in your systems. You should implement a good authorization mechanism. Checkout the following post: Authenticate user in WinForms (Nothing to do with ASP.Net)
EDIT:
You can also implement your server to accept "custom command" when you implement it as a service. This way, your client server communication will be standardized by using ServiceController to pass the command. This post might help: How to send a custom command to a .NET windows Service from .NET code?.
Don't get confused in the "command" terminology here. ServiceController issues standard commands to a service for start, stop, pause, resume and restart the service. These are the same items you see on the context menu when you right click a service in the services.msc snap-in. The same way a service can respond to custom commands. In your case the custom command maybe a request to execute a process.
Note that some mechanisms I have described are geared towards an intranet setup while others scale fine on both intranet and internet
I am maintaining a queue at the server end to which users can add files. And the queue on the app which shows the files that have been added by different users has to be dynamically updated. I dont want to poll the server periodically to check if there is any new item on the queue. Is there any way to notify the client app that a new item has arrived on the queue and u have to poll the server now to retrieve that file? And I dont want a push notification, as with push notification the user will be notified, i rather want the message to be handled internally and the app should poll the server when the message is received
Please let me know if you have any ideas, i am struck on my project because of this issue.
Thanks
Push notifications are exactly for that, although your app will have to register initially (for security) - http://weblogs.asp.net/scottgu/archive/2012/12/04/ios-support-with-windows-azure-mobile-services-now-with-push-notifications.aspx
Bitsian,
You can use Windows Azure Service Bus Notification Hubs. Its just released few days ago (not even a week). It will support multiplatform push nottification (ios,android,windows 8,win phone now)
http://msdn.microsoft.com/library/jj927170.aspx
Check this link. It has some great video tutorials to start on
I found an answer to my question. Its Web Sockets!! Web Sockets can be used to maintain persistent connections between client and server. And there is a library for that - SignalR
SignalR is a new library which was introduced for ASP.Net developers to build real time web applications where server needs to continuously push data to clients.
Some links for SignalR
http://blogs.msdn.com/b/webdev/archive/2012/12/17/signalr-building-real-time-web-applications.aspx
http://www.mikesdotnetting.com/Article/206/SignalR-And-Knockout-In-ASP.NET-Web-Pages-Using-WebMatrix
I want to write an application that "listens" for a server push.. i.e the server can broadcast.. I want to do this via an open web request to a php page that holds a database vale in it and returns the database value.. so that if the database changes.. the value changes which means C# app knows to fire a initiation of some sort (in my case it's a "refresh" request) 99.99% of this work is done via this refresh request.. I only need to know.. ho w to implement the "trigger" or "event" from the server... the standard methodology for this (I know) is polling x seconds but I know that a proper event driven architecture is much nice..
Remember this is nothing to do with IIS ... This is a windows client C# exe that needs to "listen" to a web server.. are there any good code examples people know about?
HTTP is a request/response protocol - there is no "push". Common historic approaches to solve that are frequent polling and long-polling, but these days web-sockets are another option. You can use web-sockets from a client application: in .net 4.5 on Windows 8 / Server 8 there is an inbuilt client in the framework, but it isn't hard to write one based on raw TCP from the specification (or just look for an existing client library). Web-sockets supports bi-directional communications, so the server can spontaneously broadcast to the clients. Great for prompt updates.
You would of course also need a web-socket server implementation, but that is available for most platforms and toolsets.
I want to create an application in C# with client and server sides. It will work over local network. Client sides must check for updates on a remote SQL Server. Lets say we've set update time interval to 2 seconds. If i have 20 client side applications, then they'll send query to the remote SQL Server every 2 sec and it will load server quite a lot. Now I want to know is there any way to reduce server load or it's only way to check for updates?
From my point of view, there is no need to allow clients to connect the DB serer directly. There should be one more tier here which will only connect to the server and cache information about the updates. Your clients should connect to this additional information and work with the cached info.
UPDATE
As far as I understand, the problem appears because all your clients ping your DB server every two seconds. The solution to this problem is to create a special module which will only have access to the DB server and asks it for the update. For example, every two seconds. If the update is ready, it should be able to fetch it from the DB and store. This is what I meant under the additional tier.
Now, let's return to your clients. They should be able to communicate with this module and get information from it about a ready update (this information is cached and thus it is really fast to obtain it. Also you needn't ping the server at every client request). If update is ready, fetch it to the client side and work on client side.
As for the communication between this additional tier and clients. Since you are working with .NET, I would suggest that you take a look at the WCF which, from my point of view, becomes a standard approach of implementing the between-process communication in .NET. There are a lot of information in the network about it, I will post the links shortly.
Here is my favorite WCF book:
Programming WCF Services
MSDN entry:
Windows Communication Foundation