views:

338

answers:

3

I am doing Comet chat with Erlang and PHP. But now I think I met a problem: the polling connection will disconnect and reconnect automatically in about a certain time (I set this with 10 seconds), so there will be a period of time that the user doesn't connect to chat server. If a user send message at that time, the message will be dead (no one could receive it).

In the client code I am using jquery with jsonp to realize the polling connection. Is there any good way to solve this problem?

Thanks in advance~

A: 

When a message is sent, just have jquery reconnect immediately and send the message when it does so.

asperous.us
+1  A: 

You're allowed two concurrent connections; interleave them, so that one is connecting (and pushing the user's messages to the server) while the other is listening.

Michiel Buddingh'
+1  A: 

Have a session process on the server that stores all messages while the client isn't connected. If the client doesn't connect for some (configurable) time, the session can die. When the client does connect, the session can send all queued messages to the connection.

puzza007
Maybe a good idea, like a mailbox. But I have to concern the cost if I build a mailbox for every connection. Any suggestions?
Mickey Shine
If the messages are binaries/atoms you will only be storing pointers and if the timeout is reasonable they won't have time to build up so much.
puzza007