diff --git a/lib/STP/index.js b/lib/STP/index.js index 077882d..a718db5 100644 --- a/lib/STP/index.js +++ b/lib/STP/index.js @@ -39,6 +39,10 @@ class Server extends EventEmitter { openServer() { log.info(`opening STP server on ${this.port}`); this.tcpServer = net.createServer(this.tcpConnectClient.bind(this)); + this.tcpServer.on('error', e => { + log.warn(e) + setTimeout(this.openServer.bind(this), 5000); + }) this.tcpServer.listen(this.port); } diff --git a/relay/index.js b/relay/index.js index 2da8804..fe6c8de 100644 --- a/relay/index.js +++ b/relay/index.js @@ -39,7 +39,8 @@ function connectNetwork(t = 1000) { client.on('error', e => { }); client.on('close', e => { - setTimeout(connectNetwork.bind(global, t*2), t); + t *= 2; + setTimeout(connectNetwork.bind(global, t), t); log.debug('retrying connection... ' + (t/1000) + 's') }); } @@ -52,14 +53,18 @@ const app = express(); app.get('/', (req, res) => { res.end(`