Is it possible to do client-server communication in real time via HTTP?

10
TCP sockets I can put a server application in listening and make clients connect and wait for requests on both the server and the client, having the possibility of the server sending information for ALL clients connected without any request from the client. To summarize this, I can use a MMORPG for example.

A doubt:

Is it possible to make the same type of communication in REAL TIME using HTTP ? Or would that only be possible with WebSockets ? To be clearer: it would be possible to do a MMORPG using HTTP , where clients HTTP (a browser for example, or some HTTP client like the HttpClient library do you connect to the server and make the same communication on the TCP protocol? Is the HTTP server able to send information to all connected clients?

My goal:

Create a SINGLE server, stay in listening in some protocol that I have not yet defined (so the doubt) where it will be responsible for answering requests from clients and sending in TIME REAL information for all or X cross-platform clients such as Android, iOS, desktop ( browser ). Like a Facebook or WhatsApp group chat.

asked by anonymous 12.03.2014 / 19:56

4 answers

6

My only real-time experience was with the Meteor tutorials strong>, and I recommend you take a look - it's quite impressive. Within minutes you mount a basic application with HTTP clients ( browsers ) sharing data in real time. Highly recommend!

I have little experience, but Phil Leggetter is one of the experts in this area, and in his blog he publishes regularly on the subject. The image below is from your post titled " Choosing your Realtime Web App Tech Stack

Inadditiontothe Meteor , which I already knew, he mentions Sails.js , SocketStream and DerbyJS > as " Realtime Frameworks " (it differentiates Meteor by stressing that it is not just a framework but a complete platform

But the guy is a beast! Check out:

From a long list of technologies to support real-time application building , it highlights:

Socket.IO

  

A library in Node.js with many ports for other languages.

Faye

  

Faye is a solution that offers a simple pub / sub abstraction with   support fallback . This means that it will serve the majority of   needs of a real-time application, and will work in   99% of browsers and network environments.

     

Another advantage of Faye is that it is available in Ruby and Node.js, and   much consideration was given to safety. Everything you need to   build a real-time application ready to go into production.

SockJS

  

If you want to work close to the fundamentals of WebSockets in   but also benefit from fallback mechanisms, so   SockJS is a good choice. SockJS provides a "JavaScript emulator   WebSocket client "and has available servers in Node.js, Erland,   Python / Tornado, Python / Twisted and Java. Servers in Ruby, Perl, Go and   Haskell in development.

SignalR

  

SignalR is an open source solution for ASP.NET

Well ... I hope I have collaborated with those references. Try the Meteor and ... if it does not serve, try the rest. ;-) Good luck!

    
13.03.2014 / 01:48
5

Push Technology (Ajax Push)

1. Using connection without "end"

In this technique you can use Ajax leaving it perennial with the server, when receiving the information should treat it and display it in the browser. Here the XMLHttpRequest must have the timeout set to an infinite time and the readyState will always stay 3 (receiving). The problem here is that the server has no way to control what happens "out" of the browser if the connection crashes it will be necessary to reload the page.

2. Using connection pool

This is well used today, here you maintain an XMLHttpRequest connection in the browser, waiting for server response, but renews from time to time, the server can control the connection, javascript (Ajax) should always open a connection when it is "finished". Take a look at BOSH

3. Using Flash XMLSocket

You can use flash XMLSocket by interacting with javascript in this way you could maintain an active connection with the server since XMLSocket implements situations that are not present in the javascript XMLHttpRequest.

Server-side

The whole problem is here, the server has to support the connections for a long time I know cometd that can be studied for these implementations.

    
12.03.2014 / 23:37
3

Yes, it is possible to communicate in real time with the server.

You cited something that already allows me to bring you a practical example (.NET)

In .NET technology, a real-time service called SignalR was created, with which you can work in real time. In the link, in the part next to the bottom one makes available several links by Pluralsight with explanations of the operation of SignalR.

Today in the company where I work, we are studying this technology to put into practice some projects. It is worth taking a look.

I think it will suit you very well.

Hugs

    
12.03.2014 / 20:10
0

Another option to SignalR, which has some drawbacks, such as that it does not use WebSockets if the server is not using IIS-8, is xsockets ... which creates connections on the server side independently of IIS.

    
12.03.2014 / 21:48