couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [43/50] documentation commit: updated refs/heads/import-master to fe7f7bf
Date Thu, 10 Jul 2014 09:47:42 GMT
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.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-documentation/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-documentation/commit/867bd1a0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-documentation/tree/867bd1a0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-documentation/diff/867bd1a0

Branch: refs/heads/import-master
Commit: 867bd1a08de51976da5ec3a8e19b8a6f7b9348e0
Parents: 9035fbe
Author: Damjan Georgievski <gdamjan@gmail.com>
Authored: Fri May 2 17:04:41 2014 +0200
Committer: Klaus Trainer <klaus_trainer@apache.org>
Committed: Tue May 13 14:53:42 2014 +0200

----------------------------------------------------------------------
 src/api/database/changes.rst | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-documentation/blob/867bd1a0/src/api/database/changes.rst
----------------------------------------------------------------------
diff --git a/src/api/database/changes.rst b/src/api/database/changes.rst
index fc46412..6e48f9b 100644
--- a/src/api/database/changes.rst
+++ b/src/api/database/changes.rst
@@ -398,6 +398,16 @@ parameter.
 
     }
 
+If you set a heartbeat interval (using the ``heartbeat`` query argument), CouchDB will
+send a ``hearbeat`` event that you can subscribe to with:
+
+.. code-block:: javascript
+
+    source.addEventListener('heartbeat', function () {}, false);
+
+This can be monitored by the client application to restart the EventSource connection if
+needed (i.e. if the TCP connection gets stuck in a half-open state).
+
 .. note::
 
    EventSource connections are subject to cross-origin resource sharing


Mime
View raw message