added ipc.config.stopRetrying for clients
This commit is contained in:
parent
a1f3c5cbdb
commit
90e529874b
3 changed files with 24 additions and 10 deletions
|
@ -8,7 +8,8 @@ function init(config,log){
|
||||||
socket : false,
|
socket : false,
|
||||||
connect : connect,
|
connect : connect,
|
||||||
emit : emit,
|
emit : emit,
|
||||||
log : log
|
log : log,
|
||||||
|
retryCount:0
|
||||||
}
|
}
|
||||||
new pubsub(client);
|
new pubsub(client);
|
||||||
|
|
||||||
|
@ -33,13 +34,6 @@ function connect(){
|
||||||
//init client object for scope persistance especially inside of socket events.
|
//init client object for scope persistance especially inside of socket events.
|
||||||
var client=this;
|
var client=this;
|
||||||
|
|
||||||
if(client.socket){
|
|
||||||
if(client.socket.destroyed){
|
|
||||||
client.log('Requested to connect or reconnect to a destroyed socket. Not attempting because socket distroyed'.notice);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
client.log('requested connection to '.debug, client.id.variable, client.path.variable);
|
client.log('requested connection to '.debug, client.id.variable, client.path.variable);
|
||||||
if(!this.path){
|
if(!this.path){
|
||||||
client.log('\n\n######\nerror: '.error, client.id .info,' client has not specified socket path it wishes to connect to.'.error);
|
client.log('\n\n######\nerror: '.error, client.id .info,' client has not specified socket path it wishes to connect to.'.error);
|
||||||
|
@ -83,11 +77,30 @@ function connect(){
|
||||||
'close',
|
'close',
|
||||||
function(){
|
function(){
|
||||||
client.log('connection closed'.notice ,client.id.variable , client.path.variable);
|
client.log('connection closed'.notice ,client.id.variable , client.path.variable);
|
||||||
|
|
||||||
|
if(client.config.stopRetrying || client.config.stopRetrying===0){
|
||||||
|
if(client.retryCount++>client.config.stopRetrying){
|
||||||
|
client.log(client.config.id.variable,'exceeded connection rety amount of'.warn,client.config.stopRetrying);
|
||||||
|
client.socket.destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client.isRetrying=true;
|
||||||
|
|
||||||
setTimeout(
|
setTimeout(
|
||||||
(
|
(
|
||||||
function(client){
|
function(client){
|
||||||
return function(){
|
return function(){
|
||||||
|
client.isRetrying=false;
|
||||||
client.connect();
|
client.connect();
|
||||||
|
setTimeout(
|
||||||
|
function(){
|
||||||
|
if(!client.isRetrying)
|
||||||
|
client.retryCount=0;
|
||||||
|
},
|
||||||
|
100
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)(client),
|
)(client),
|
||||||
|
|
|
@ -26,7 +26,8 @@ var defaults={
|
||||||
encoding : 'utf8',
|
encoding : 'utf8',
|
||||||
silent : false,
|
silent : false,
|
||||||
maxConnections : 100,
|
maxConnections : 100,
|
||||||
retry : 500
|
retry : 500,
|
||||||
|
stopRetrying : false,
|
||||||
}
|
}
|
||||||
|
|
||||||
var ipc = {
|
var ipc = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "node-ipc",
|
"name": "node-ipc",
|
||||||
"version": "0.9.11",
|
"version": "0.9.13",
|
||||||
"description": "A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.",
|
"description": "A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.",
|
||||||
"main": "node-ipc.js",
|
"main": "node-ipc.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|
Loading…
Reference in a new issue