Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there some way to PUSH data from web server to browser?

People also ask

Can server push data to client?

It needs to be clear in mind that in HTTP protocol, the server can't send any data without getting a request from the client which is actually a case of PUSH. So server can't PUSH data over HTTP to the client if it's not requested.

What is Reverse Ajax?

Reverse Ajax: is essentially a concept: being able to send data from the server to the client. In a standard HTTP Ajax request, data is sent from client to the server. Other simmilar terms are HTTP Polling, Long Polling, Comet, Server Push, Web Sockets in HTML5.


Yes, what you're looking for is COMET http://en.wikipedia.org/wiki/Comet_(programming). Other good Google terms to search for are AJAX-push and reverse-ajax.


Yes, it's called Reverse Ajax or Comet. Comet is basically an umbrella term for different ways of opening long-lived HTTP requests in order to push data in real-time to a web browser. I'd recommend StreamHub Push Server, they have some cool demos and it's much easier to get started with than any of the other servers. Check out the Getting Started with Comet and StreamHub Tutorial for a quick intro. You can use the Community Edition which is available to download for free but is limited to 20 concurrent users. The commercial version is well worth it for the support alone plus you get SSL and Desktop .NET & Java client adapters. Help is available via the Google Group, there's a good bunch of tutorials on the net and there's a GWT Comet adapter too.


Nowadays you should use WebSockets. This is 2011 standard that allows to initiate connections with HTTP and then upgrade them to two-directional client-server message-based communication.

You can easily initiate the connection from javascript:

var ws = new WebSocket("ws://your.domain.com/somePathIfYouNeed?args=any");
ws.onmessage = function (evt) 
{
  var message = evt.data;
  //decode message (with JSON or something) and do the needed
};

The sever-side handling depend on your tenchnology stack.


Look into Comet (a spoof on the fact that Ajax is a cleaning agent and so is Comet) which is basically "reverse Ajax." Be aware that this requires a long-lived server connection for each user to receive notifications so be aware of the performance implications when writing your app.

http://en.wikipedia.org/wiki/Comet_(programming)


Comet is definitely what you want. Depending on your language/framework requirements, there are different server libraries available. For example, WebSync is an IIS-integrated comet server for ASP.NET/C#/IIS developers, and there are a bunch of other standalone servers as well if you need tighter integration with other languages.