We are looking into a better way to deliver data update notifications to a web front end.
These notifications trigger events that execute business logic and up-date elements via JavaScript (JS) to dynamically update the page without reloading.
Currently this is done with a server side thread, which timely fires an A-synch JS event to notify the web front-end(s) to check if the data has been changed or not.
This mechanism works, but the feeling within the team is that it could be a lot more efficient.
The tool is written in C# / ASP.NET combined with JS and we use the PokeIn library for the aSynch JS/C# Calls.
Any suggestions for improved functionality are welcome! Including radically different approaches still maintaining the JS/C#/ASP.NET usage.
Is this a real question? I would like to add this as a comment but I don't have the enough score.. Anyway, if you need what pokein does for you (object translation among the parties) that is the only option you have. Although there are solutions like websync, signalr.. They don't handle the object translation and has no different approach etc... Better, you benefit from pokein's websocket feature. Both of others needs Windows Server 8 for websocket. Pokein lets you use websocket on any server version or platform..
Sounds like SignalR would help you? This blog post gives a good introduction.
I was trying to solve something similar (reporting real-time updates triggered from an external services communicating with the server) recently and it turned out SignalR is a perfect fit for this situation.
Basically it is a library wrapping long-polling, Web Sockets and few other techniques, using (transparently) whatever is available on server and client.
I only have good experience with it so far.
Related
I am currently involved in a simple to medium complex IOT project. The main purpose of our application is gathering data from our devices and analyzing that data as well as calculating statistics.
On the server side we run a MVC application. Up until now we used Hangfire to schedule the calculations. Hangfire is an amazing tool for scheduling emails and other simple stuff, for more advanced things it's too slow. The calculations can take up a lot of time and are processor-intensive (we are trying to optimize them though), so we need to call them in a background task, a simple API call won't be enough.
I thought about splitting the application into multiple parts, the website, the core and a windows service.
The problem is, I never tried that before and I have no idea what the best practice is to achieve that kind of thing. I searched for examples and articles, but all I found were suggestions to use Hangfire and/or Quartz.NET.
Does anyone have any resources on what the best practice is to build a MVC application, a Windows service and how they could communicate (probably through a queue)? What is the best practice in such a situation?
Although there may be many different possible ways to connect a site with a windows service, I'd probably chose one of the following two, based on your statements:
Direct communication
One way of letting your site send data to your backend windows service would be to use WCF. The service would expose an endpoint. For simplicity's sake this could be a basicHttpBinding or a netTcpBinding. The choice should be made based on your specific requirements; if the data is small then basicHttp may be "sufficient".
The advantage of this approach is that there's relatively little overhead needed: You'll just have to setup the windows service (which you'll have to do anyway) and open a port for the WCF binding. The site acts as client, the service as server. There's nothing special with it, just because the client being a MVC site. You can take almost any WCF tutorial as a starting point.
Note that instead of WCF you could use another technology like .NET Remoting or even sockets just as well. Personally, I often use WCF because I'm quite used to it, but this choice is pretty opinion based.
Queued communication
If reliability and integrity is crucial for your project, then using a queue might be a good idea. Again: depending on your needs, there may come diffeent products into consideration. If you don't need much monitoring and out-of-the-box management goodies, then even a very simplistic technology like MSMQ may be sufficient.
If your demands to the aforementioned points are more relevant, then maybe you should look for something else. Just recently I got in touch with Service Bus for Windows Server (SBWS). It's the Azure Service Bus's little brother which can be used on premises locally on your windows server. The nice thing about it is, that it comes at no extra charge as it's already licensed with your windows server licence.
As with the first point: MSMQ and SBWS are just two examples. There may be a lot of other products like NServiceBus, ZeroMQ or others usable, you name it.
There is an ASP.net C# web application through which we can get the recipient emails, time zone and their smtp server details in to the database.I have two requirements:
1. Consider a table in the database. When ever there is a change in the table, an email has to be sent. It is OK if we can constantly check the database every 5 minutes. It would be great if we can send it instantly but a delay is fine.
2. Sending emails automatically at 12 AM at their respective time zone.
I m familiar with C# programming. But kind of new to automatic scheduling stuff. This could sound like a basic question but it would be great if you can help. What is the best way to implement this - Web api or web services or WCF or windows services or combination of web api and task scheduler? Please let me know your thoughts. Also a small tip on how to implement this would be great.
You have an option of setting up trigger but I hate that approach as it will add overhead to your table tow insertion and not actually needed. I think you are in the right path by thinking about pooling. There is a nice little library in .net called hangfire which I find to be very useful to do scheduled task. It has pretty sophisticated reporting and almost all the time works really well. You can give it a try. But if you want to control things better writing a small windows service don't be that bad either. I think doing websevice either using webapi or wcf is a bit overkill here and might not fit purpose.
I have a quite advanced application, where I need to add some client/server functionality. Some examples of functionalities is:
Chat
One vs. one fight in a browser game
Draw people on a map
I am creating this application in ASP.NET and AJAX. I do not use Silverlight/Java Applet/Flash or anything else. If possible, I do not want to change this for other reasons.
I thought about creating some kind of game server, and then communicating either web services or TCP protocol: But I have NO idea if this is a good idea. Also, I don't know how to do this.
So my question is:
What's the best way to implement this? And is it even possible? And if it is, could you give a reference or two?
Thanks a lot,
Lars
For doing chat & multiplayer games, the crux of the problem is in getting the server to asynchronously send messages to the client. This can be accomplished by a method called reverse-Ajax (or commet). Here is a simple example for how to do reverse-Ajax with ASP.NET. This is a very involved concept (at least until we can use HTML5 WebSockets) with a lot of thought going into security concerns, et al. I assume that by asking this question you are already quite familiar with Ajax & browser scripting (if not, you have a lot of reading to do).
Tutorial on writing a basic chat server: (in c# no less)
http://www.dreamincode.net/forums/topic/33396-basic-clientserver-chat-application-in-c%23/
Sgive you a good foundation on server development.
i need to update client on any changes occurred on server.
for that i found 2 approach.
1. using ajax which is also known as reverse ajax for this purpose.
2. using COMET.
but i don't know exact difference in both.
my site contains news content and i want that news to be automatically updates when new news is entered by my CMS application.
i have got hundreds of concurrent users on my web application.
please suggest me which approach should i use to get best solution.
also please provide me good example's like for that so that i can implement it.
NOTE: i am using .net framework 2.0 but if its not possible in 2.0 then can also move to 3.5
Thanks.
First start with YAGNI principle. See if it is ok for your client to update periodically, lets say every min or every 30 seconds. Consider things like how much information users can process in this interval. Also take a look at popular news site and how they implement this feature. In this case you are better off using the pull model where your client updates itself by requesting data from server. Implementing a push model is much more complicated.
Once you are sure that you need the push model, IMO comet is a better option. Coment is designed for this purpose. Dojo Foundation's CometD is a widely used library for this purpose. One good example is the live chess application on chess.com
Also, though I am not 100% sure about this, I believe you will need to use technologies like ASP.NET MVC which will allow you more control on the markup generated by your web app so that you can use these libraries.
I've started with Flex recently, I've noticed that some plugin for Visual Studio exist, instead of buying a licence for another program (Flex Builder).
I was wondering how I could manage to remotely connect to my database with a Flash/Flex application with the help of C#/Asp.Net.
If I've correctly understood what I've read in the last few days, there is basically no way to 'query' to a database with Flex 3. So I suppose there is another way by using a webservice in C# on the database server that would respond to the Http query from Flex.
Am I right or totally of the track? If you have any other thoughts about this, please share.
I prefer (and recommend) using Webservices for the communication between Flex and C#. It's easy to use, and they both support serialization, so you can easily transfer Strong-Typed Objects. More on Flex and .NET can be found at http://www.adobe.com/devnet/flex/flex_net.html
Alternatively, you could consider using WebORB. This program functions as a gateway between and Flex, and enables you to use the Flash RemoteObject API for the communication to C#. More on this can be found at http://www.adobe.com/devnet/flex/articles/flextodotnet_remoteobject.html.
You really should consider using FluorineFx.
It takes about 5 minutes to set up an will allow Flex to call your methods like a service. You can then pass classes back and forth from .NET to Flex and back.
It's also the standard form of communication by Adobe, it's free and it's super fast.
Your understanding is correct. Flex is intended for developing client-side applications, and communication with a database is done through a server-side application.
Pretty much the same as building a JavaScript application. Though, Flex has several additional options for communicating with the backend. Webservices are great in a lot of cases, but the other options are worth looking into.
Here's a pretty happening article on the topic, if you haven't already seen it.
http://www.dehats.com/drupal/?q=node/33