Skip to content

Commit 605ed70

Browse files
author
Trevor Rawlings
committed
Manually applied jmesnil#34
1 parent 731a6be commit 605ed70

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lib/stomp-node.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/stomp.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/stomp.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ class Client
140140
# (value in ms)
141141
incoming: 10000
142142
}
143+
# Send pings 10% faster and allow pongs 10% slower to account for
144+
# inaccurate timing in the web browser
145+
@heartbeatWindow = 0.10 #10%
143146
# maximum *WebSocket* frame size sent by the client. If the STOMP frame
144147
# is bigger than this value, the STOMP frame will be sent using multiple
145148
# WebSocket frames (default is 16KiB)
@@ -193,6 +196,7 @@ class Client
193196

194197
unless @heartbeat.outgoing == 0 or serverIncoming == 0
195198
ttl = Math.max(@heartbeat.outgoing, serverIncoming)
199+
ttl = ttl - (ttl * @heartbeatWindow);
196200
@debug? "send PING every #{ttl}ms"
197201
# The `Stomp.setInterval` is a wrapper to handle regular callback
198202
# that depends on the runtime environment (Web browser or node.js app)

0 commit comments

Comments
 (0)