[Pkg-javascript-commits] [ltx] 85/469: router: tcp keepAlive

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:01:06 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository ltx.

commit 35b2a9fd33fe6b435a81145855320369148ecab4
Author: Astro <astro at spaceboyz.net>
Date:   Mon Sep 6 01:49:59 2010 +0200

    router: tcp keepAlive
---
 lib/xmpp/router.js | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/xmpp/router.js b/lib/xmpp/router.js
index a7a60bf..275c480 100644
--- a/lib/xmpp/router.js
+++ b/lib/xmpp/router.js
@@ -90,8 +90,9 @@ DomainContext.prototype.getOutStream = function(domain) {
 	this.s2sOut[domain] = outStream;
 	dbgStream('outgoing', outStream);
 
-	StreamShaper.attach(outStream, this.router.rateLimit);
 	outStream.maxStanzaSize = this.router.maxStanzaSize;
+	StreamShaper.attach(outStream, this.router.rateLimit);
+	outStream.setKeepAlive(true, this.router.keepAlive);
 	this.setupStream(domain, outStream);
 
 	outStream.addListener('close', function() {
@@ -217,8 +218,7 @@ DomainContext.prototype.receive = function(stanza) {
 
 /**
  * TODO:
- * * timeouts
- * * keepAlive
+ * * connect timeouts, stream idle timeouts
  * * TLS
  */
 function Router(s2sPort) {
@@ -226,6 +226,7 @@ function Router(s2sPort) {
     this.ctxs = {};
 
     net.createServer(function(inStream) {
+	console.log('INCOMING from ' + inStream.remoteAddress);
 	self.acceptConnection(inStream);
     }).listen(s2sPort || 5269);
 }
@@ -233,15 +234,16 @@ exports.Router = Router;
 
 Router.prototype.rateLimit = 1E6;  // 100 KB/s, it's S2S after all
 Router.prototype.maxStanzaSize = 65536;  // 64 KB, by convention
+Router.prototype.keepAlive = 30000;  // 30s
 
 Router.prototype.acceptConnection = function(inStream) {
     var self = this;
 
-    Server.makeIncomingServer(inStream);
+    dbgStream('incoming', inStream);
     inStream.maxStanzaSize = this.maxStanzaSize;
     StreamShaper.attach(inStream, this.rateLimit);
-    console.log('INCOMING from ' + inStream.remoteAddress);
-    dbgStream('incoming', inStream);
+    inStream.setKeepAlive(true, this.keepAlive);
+    Server.makeIncomingServer(inStream);
 
     // incoming server wants to verify an outgoing connection of ours
     inStream.addListener('dialbackVerify', function(from, to, id, key) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git



More information about the Pkg-javascript-commits mailing list