Setting timeout and heartbeat to the same value is going to lead to exactly what you're seeing.
The timeout setting is how long, without an event, the connection will stay open. The heartbeat setting is how long to wait, without an event, before sending a newline character to keep the connection from timing out. What you're seeing is that the timeout happens before the heartbeat, since both are happening approximately simultaneously. Just set heartbeat=5000 and rely on the timeout default of 1 minute, or specify timeout to whatever multiple of heartbeat you find useful (as long as it's more than one). Summary: timeout == heartbeat is not going to keep the connection alive. B. On 17 April 2013 10:29, Stephen Bartell <[email protected]> wrote: > Ok heres a test script. Have a couch serving localhost:5984 in admin party > mode. > > git clone https://github.com/snbartell/couch-es-test.git > cd couch-es-test > npm install > node index.js > > My theory of a second source crashing couch was wrong. > > I think I know whats going on. My script above acts just like the browser > does. When the `timeou`t is reached and `heartbeat` !== `timeout`, the > EventSource module (whether its the browser or the node package) will restart > the feed. This is why every `timeout` ms the feed __appears__ to by dumping > all the docs since `since`. > > curling works fine. Try this after running the above script and leaving the > test db in place. I expect this behavior. > curl > "http://localhost:5984/source1/_changes?since=2&feed=continuous&timeout=5000&heartbeat=5000" > > So then it comes to using this in Chrome console. If you go to the couch you > ran the script against, open the console, and paste the following: > var source1 = new > EventSource('/source1/_changes?feed=eventsource&timeout=5000&heartbeat=5000') > > Watch the Network panel. It looks like EventSource does not pass the query > params. I'm probably being an idiot and not calling it correctly. I googled > around and couldn't find the api. Does someone have a link? > > Still though, if I call EventSource without `timeout` and `heartbeat`, then > couchdb will use the defaults of 60000 each. Then, with `timeout` === > `heartbeat`, the connection should be kept alive, right? > > Thanks guys, > > Stephen > > > On Apr 16, 2013, at 11:17 PM, Stephen Bartell <[email protected]> wrote: > >> >> On Apr 16, 2013, at 11:13 PM, Benoit Chesneau <[email protected]> wrote: >> >>> On Wed, Apr 17, 2013 at 7:55 AM, Stephen Bartell <[email protected]> >>> wrote: >>>> >>>> But for what I was doing, no, I wasn't specifying since. I would expect >>>> the fundamentals to be the same as well. What I was see is that even >>>> without `since` given, no changes would come through until that second >>>> source was added. Once the second source is added, then all sources >>>> periodically dump. >>>> >>> >>> Hi Stephen, >>> >>> Can you provide a clear way to reproduce what you're doing and the >>> result you're expecting. It's not clear for me right now if you : >> >> Yep, Im actually working on it now :) >> >>> >>> 1. the reauest results when giving the since parameter without any >>> changes , did you try using curl? >> no. I only did it from the browser console. >> >>> 2. If it's a javascript error >> nope. its a couch thing. >> >>> 3. ? >>> >>> - benoit >> >
