couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <rnew...@apache.org>
Subject Re: EventSource periodically dumps db contents.
Date Thu, 18 Apr 2013 07:40:10 GMT
Hi Stephen,

feed=eventsource just changes the format of the continuous response,
nothing else changes. It might have been a clearer api to have chosen
feed=continuous&format=eventsource but that didn't happen. In code
terms, we run through the same places as feed=continuous.

B.

On 18 April 2013 07:16, Benoit Chesneau <bchesneau@gmail.com> wrote:
> continuous mode isn't supported by all browsers.
>
> - benoit
>
> On Thu, Apr 18, 2013 at 7:28 AM, Stephen Bartell <snbartell@gmail.com> wrote:
>> Thanks for the summary Robert. That clears it all up :)
>>
>> Ok so now I'm going to risk looking like a tool.  Besides the underlying mechanism,
what is the difference between eventsource and continuous?  In other words, what does ES bring
to the table that continuous does not?  I was originally excited about event source because
for some reason i had it in my head that  multiple event source subscriptions would use the
same connection, thus circumventing the open connection limits on browsers.
>>
>> Best
>> Stephen
>>
>> On Apr 17, 2013, at 4:31 AM, Robert Newson <rnewson@apache.org> wrote:
>>
>>> 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 <snbartell@gmail.com> 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 <snbartell@gmail.com>
wrote:
>>>>
>>>>>
>>>>> On Apr 16, 2013, at 11:13 PM, Benoit Chesneau <bchesneau@gmail.com>
wrote:
>>>>>
>>>>>> On Wed, Apr 17, 2013 at 7:55 AM, Stephen Bartell <snbartell@gmail.com>
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
>>>>>
>>>>
>>

Mime
View raw message