GitHub user gdamjan opened a pull request:

    https://github.com/apache/couchdb/pull/222

    Send a real EventSource event for heartbeat

    The EventSource connection can get stuck (in TCP half-open state*) and 
there's no way
    for the client to detect that. This commit changes the way heartbeat is 
sent, instead of
    sending a newline character, it sends an empty event of type heartbeat:
    
        event: heartbeat
        data:
    
    This event doesn't have an id: field, so the client will retain its latest 
Last-Event-ID state.
    
    This doesn't change the expectations of clients that used EventSource till 
now, because they
    subscribe to the 'message' event type. To get the 'heartbeat' events a 
client will need to
    explicitly subscribe to it:
    
        source.addEventListener('heartbeat', function () { /* cancel a timer 
that would otherwise reconnect the source */ });
    
    * this can happen when you suspend your laptop, on flaky internet 
connection, ADSL reconnect,
    bad wifi signals, bad routers etc. Pretty often in a typical internet usage 
nowadays.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/gdamjan/couchdb master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb/pull/222.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #222
    
----
commit a3de553727e35b5ac8f22c0768f2aa6c08ad4654
Author: Damjan Georgievski <[email protected]>
Date:   2014-05-02T15:04:41Z

    Send a real EventSource event for heartbeat
    
    The EventSource connection can get stuck (in TCP half-open state*) and 
there's no way
    for the client to detect that. This commit changes the way heartbeat is 
sent, instead of
    sending a newline character, it sends an empty event of type heartbeat:
    
        event: heartbeat
        data:
    
    This event doesn't have an id: field, so the client will retain its latest 
Last-Event-ID state.
    
    This doesn't change the expectations of clients that used EventSource till 
now, because they
    subscribe to the 'message' event type. To get the 'heartbeat' events a 
client will need to
    explicitly subscribe to it:
    
        source.addEventListener('heartbeat', function () { /* cancel a timer 
that would otherwise reconnect the source */ });
    
    * this can happen when you suspend your laptop, on flaky internet 
connection, ADSL reconnect,
    bad wifi signals, bad routers etc. Pretty often in a typical internet usage 
nowadays.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to