From 09a98f6b3a58246853d6ce0a8e4e16bc1bedf258 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 12 Oct 2016 19:11:11 -0400 Subject: [PATCH] close on error --- wstunneld.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wstunneld.js b/wstunneld.js index eb309ee..9f53280 100644 --- a/wstunneld.js +++ b/wstunneld.js @@ -189,7 +189,15 @@ module.exports.create = function (opts) { // var chunk = socket.read(); console.log('[bstream] data from browser to tunneler', pchunk.byteLength); //console.log(JSON.stringify(pchunk.toString())); - ws.send(pchunk, { binary: true }); + try { + ws.send(pchunk, { binary: true }); + } catch(e) { + try { + bstream.browser.end(); + } catch(e) { + // ignore + } + } }); bstream.wrapped.on('error', function (err) { console.error('[error] bstream.wrapped.error');