Skip to content

Commit 4e556c4

Browse files
author
Swapnil Tailor
committed
Adding timeout to stomp
1 parent 4184d0d commit 4e556c4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/stomp.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ function _connect(stomp) {
110110
} else {
111111
log.debug('Connecting to ' + stomp.host + ':' + stomp.port);
112112
stomp.socket = new net.Socket();
113+
if(stomp.timeout) {
114+
stomp.socket.setTimeout(stomp.timeout);
115+
}
113116
stomp.socket.connect(stomp.port, stomp.host);
114117
_setupListeners(stomp);
115118
}
@@ -161,6 +164,11 @@ function _setupListeners(stomp) {
161164
log.debug("end");
162165
});
163166

167+
socket.on('timeout', function() {
168+
log.debug('socket timed out');
169+
stomp.emit("timeout");
170+
}
171+
164172
socket.on('error', function(error) {
165173
log.error(error.stack + 'error name: ' + error.name);
166174
stomp.emit("error", error);

0 commit comments

Comments
 (0)