Skip to content
Snippets Groups Projects
Commit a1076371 authored by Micah Elizabeth Scott's avatar Micah Elizabeth Scott
Browse files

Merge pull request #56 from pollonamid/master

add connection error handling and reconnect
parents 3ba592db 20eda7b9
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,13 @@ OPC.prototype._reconnect = function()
_this.connected = false;
}
this.socket.on('error', function(e){
if(e.code == 'ECONNREFUSED' || e.code == 'ECONNRESET') {
_this.socket = null;
_this.connected = false;
}
});
this.socket.connect(this.port, this.host, function() {
console.log("Connected to " + _this.socket.remoteAddress);
_this.connected = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment