0

I am trying to make Comet requests via Prototype/php like here : http://www.zeitoun.net/articles/comet_and_php/start

But!!! While connection is open, other pages from my project is not loading from the same browser. What can I do to provide normal behaviour?

Very very tnx

Joeeee
  • 1,256
  • 6
  • 18
  • 25
  • Afaik comet is not really well supproted everywhere ... Im working on etherpad and with firefox/safari on mac it goes back to a "lots of rapid and small requests" custom mode because it does not support the long polling stuff ... Did you also check server's output buffering config, because if servers awaits a flush or script end to send something, the browser may hang. – yent Mar 14 '11 at 14:39
  • I found the problem. It is cause of not native implementation, Comet ideology(without comet server) is implemented trough hack (iframe) without that it will be not responding to other requests. But it is IMHO ^^ – Joeeee Mar 14 '11 at 15:11

1 Answers1

3

Comet works by keeping a connection open between the server and the client. Browsers have a maximum number of connections that they will allow a page to make (something like 2 max for IE), I think it might also group all requests for the same domain together. That is why connections are not going through for you.

I believe it is not the server that is at fault here it is the browsers, using an iframe is the correct solution here as you mentioned, but it's not the servers fault.

[Edit] Simplest solution for you is to monitor focus. When the page has focus, open a connection, when it is lost(ie. user switches tabs) close the connection and wait for focus again before updating the page. That way you will have the appearance of multiple pages updating while only needing 1 comet connection at any time.

Andrew
  • 13,757
  • 13
  • 66
  • 84