diff --git a/lib/remote-server.js b/lib/remote-server.js index 7e246b5..486c5e3 100644 --- a/lib/remote-server.js +++ b/lib/remote-server.js @@ -21,7 +21,7 @@ class RemoteServer { return new Promise((resolve, reject) => { this._config = opts; - const wssOpts = { port: opts.port }; + const wssOpts = { port: opts.port, maxPayload: 256 * 1024 }; if (opts.host) wssOpts.host = opts.host; this._wss = new WebSocketServer(wssOpts, () => { resolve(); @@ -175,7 +175,9 @@ class RemoteServer { sendToClient(clientId, data) { for (const [ws, client] of this._clients) { if (client.id === clientId && client.authenticated) { - ws.send(JSON.stringify(data)); + if (ws.readyState === 1) { + try { ws.send(JSON.stringify(data)); } catch {} + } break; } }