# Strange "long polling" problem

**URL:** <https://www.ruby-forum.com/t/strange-long-polling-problem/214442>\
**Category:** NGINX\
**Created:** [December 2, 2011, 12:29am UTC](https://www.ruby-forum.com/t/strange-long-polling-problem/214442 "2011-12-02T00:29:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [December 2, 2011, 12:29am UTC](https://www.ruby-forum.com/t/strange-long-polling-problem/214442/1 "2011-12-02T00:29:07Z")

</div>

Hi All,

I am having a problem with my Chatroom, that uses the long polling  
module linked with nginx version 1.0.6

First the structure.  
There are two http conversations going on with each client.  
GETs, created by “on-load” and receiving the previous message, are  
issued to the long polling “activity” address.  
When the data arrives, it updates the screen, as well as triggering the  
next “GET”. Note - there is a small time gap between one message being  
sent and the next being requested.

POSTS are triggered by user events. These send a separate XMLHTTPRequest  
to a php program - handlechat.php

handlechat.php writes the relevant stuff to the database, and then  
issues a “curl” to write data to the “publish” address, and replies with  
an empty “200” reply.

It works 99.9% of the time. Which is not quite 100%. ☹

When it fails  
The client’s GET is outstanding (reported by chrome)  
The database has the missed message  
The curl write to the publish address replies with first

queued messages: 1  
last requested: 12 sec. ago (-1=never)  
active subscribers: 2  
then  
queued messages: 1  
last requested: 13 sec. ago (-1=never)  
active subscribers: 2

I know both CURLs worked. The “missing” message is received by the  
other user. It just is not received by the failing user.  
If the failing user refreshes the screen, thus re-initialising  
everything he getst the missing message twice, once from the log  
and once from the stalled message.

As part of my testing, I tried INCREASING the delay between getting an  
update and requesting the next. This made the problems much much worse.

It appears that messages posted after a reply is sent, and before the  
next request is received are not being sent on.

Note - I return the etag in the header, so I think they should be.

What is the correct method to over-come this problem?

Regards

Ian

–  
Ian H.  
31 Sheerwater, Northampton NN3 5HU,  
Tel: 01604 513875  
Preparing eBooks for Kindle and ePub to give the best reader experience.

---

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [December 2, 2011, 11:49pm UTC](https://www.ruby-forum.com/t/strange-long-polling-problem/214442/2 "2011-12-02T23:49:17Z")

</div>

Hi all,

Can someone who is using the long polling module (either version .69 or  
.692) please respond and at least confirm that it does  
or does not work?

Thanks

Ian

–  
Ian H.  
31 Sheerwater, Northampton NN3 5HU,  
Tel: 01604 513875  
Preparing eBooks for Kindle and ePub to give the best reader experience.
