How to create a chat server that is not polled?

I created a simple chat server that is controlled by client polling. Clients send data requests every few seconds and receive any new messages, as well as information about whether everyone is connected to them.

Since the client runs on a mobile platform (iPhone), I was looking for ways to get rid of the survey, which quickly drains the battery. I read that it is possible to support an undefined http connection, but did not understand how to use this technique in practice. I am also wondering if such connections are stable enough for use in mobile setup.

The ideal scenario would be that the server sends data only to clients when an event has occurred that affects them (for example, a peer message or a failure).

Can I try to do this via http, or do I need to write my own tcp protocol? How difficult it would be to configure xmpp to my need (my chat server has some specialized functions that I should have easily implemented).

+4
source share
5 answers

What about push technology? see http://en.wikipedia.org/wiki/Comet_(programming)

+4
source

I think you are describing XMPP over BOSH.

http://xmpp.org/extensions/xep-0206.html

I used this http bind method between chat server and javascript client on non-mobile devices. It worked for me.

+3
source

I just found this article that describes the following method (which I mentioned in the question):

... the client makes an HTTP request and the server holds the request in the queue until a push message appears. if the TCP / IP connection is lost or timeouts, the client will make a new HTTP request, and the delay will only be round-trip time for the request / response., This model effectively requires two TCP / IP connections for HTTP, the client server, although neither one of them is not therefore mobile friendly

+1
source

You might like this project , which uses many methods, including Comet. Release notes are here , here is a snippet from this page.

It’s my pleasure to be able to announce the first public display of the project, which I have been working on in my free time in the last month or two, the new IRC web chat application.

This project brings together many new technologies that needed to be made feasible, scalable and efficient.

Some of the main tools, make it possible that I think the stable ones are already released, for example, the php Socket Daemon library I wrote to deal with from hundreds to many thousands of Http connections "Comet" and equal number of client IRC connections.

+1
source

I think this is almost impossible and dangerous. The Internet works without citizenship and without establishing a connection, which means that the connection between the client and server is always treated as unreliable. And this is not for pleasure.

When you try to get a state connection, you introduce new problems. Especially from the 3g application. What if the connection breaks? You do not control the server and cannot click.

I think it would be easier to send sms / text messages and have an application that handles this.

0
source

All Articles