aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sockets.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sockets.js')
-rw-r--r--lib/sockets.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sockets.js b/lib/sockets.js
index ee453ce7..adea1fa3 100644
--- a/lib/sockets.js
+++ b/lib/sockets.js
@@ -37,6 +37,7 @@ const names = {};
wss.on("connection", function (ws) {
const id = uuidv4();
+ setTimeout(() => ws.ok || ws.close(), 2000);
ws.on("message", async (token) => {
if (!token || token === "null") return;
@@ -46,11 +47,13 @@ wss.on("connection", function (ws) {
sockets[username][id] = ws;
names[id] = username;
+ ws.ok = true;
ws.send(JSON.stringify({ type: "networks", data: networks }));
ws.send(JSON.stringify({ type: "rates", data: app.get("rates") }));
ws.send(JSON.stringify({ type: "login", data: await getUser(username) }));
l.info("socket open", username, id);
} catch (e) {
+ ws.close();
l.error("problem opening socket", token, e.message, id);
}
});