Permalink
Browse files

add error/timeout tracing for nodeSP

  • Loading branch information...
1 parent 318094c commit 1e33b4b0faa7bc21dd0154dbb43a54752c6099c4 @kaven276 committed Sep 5, 2012
Showing with 18 additions and 9 deletions.
  1. +18 −9 lib/nodes/nodeSP.js
View
27 lib/nodes/nodeSP.js
@@ -38,6 +38,24 @@ SP.prototype.connect = function(){
, client = me.socket = new net.Socket()
, bound = false
;
+
+ client.on('close', function(){
+ me.linkStatus = false;
+ console.log('SMG server close');
+ });
+ client.on('end', function(){
+ me.linkStatus = false;
+ console.log('SMG server end');
+ });
+ client.on('error', function(){
+ console.log('SMG connection has error!');
+ console.log(me);
+ });
+ client.on('timeout', function(){
+ console.log('SMG connection has timeout!');
+ });
+
+ console.log('try to connect to SMG with %s:%s', me.SMGHost, me.SMGPort);
client.connect(me.SMGPort, me.SMGHost, function(){
console.log('SMG connected');
var bind = new Bind(1, me.SMGUser, me.SMGPass);
@@ -67,15 +85,6 @@ SP.prototype.connect = function(){
}
}
});
-
- client.on('close', function(){
- this.linkStatus = false;
- console.log('SMG server close');
- });
- client.on('end', function(){
- this.linkStatus = false;
- console.log('SMG server end');
- });
});
};

0 comments on commit 1e33b4b

Please sign in to comment.