Skip to content

Commit

Permalink
Fix missing error if initial connection cannot be established.
Browse files Browse the repository at this point in the history
E.g. if the IP address of the server is wrong: Currently the socket setup
just runs forever, but the situation of a wrong server address should
better be handled somehow.
  • Loading branch information
Christian Stimming committed Oct 10, 2020
1 parent 9c57d9a commit 2eddb65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dcom/rpc/stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Stub extends Events.EventEmitter {
transport = this.endpoint.transport;
await transport.attach()
.catch(function(reject) {
debug(reject);
throw new Error(reject)
});
}

Expand Down
4 changes: 4 additions & 0 deletions dcom/transport/comtransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class ComTransport extends events.EventEmitter

channel.on('error', function(data){
self.emit('disconnected');
reject(data)
});

channel.on('close', function(){
Expand All @@ -116,7 +117,10 @@ class ComTransport extends events.EventEmitter
}
});

const connectFailedTimer = setTimeout(() =>
channel.emit('error', 'Connection could not be established'), self.timeout)
channel.connect(Number.parseInt(self.port), self.host, () => {
clearTimeout(connectFailedTimer)
self.attached = true;
channel.setKeepAlive(true);
self.channelWrapper = channel;
Expand Down

0 comments on commit 2eddb65

Please sign in to comment.