Last active
July 26, 2023 17:52
-
-
Save shortthefomo/3360e4d2df22a11489ab65c1b68a1959 to your computer and use it in GitHub Desktop.
websocket memory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WebSocketServer = require('ws').Server | |
// dissable the perMessageDeflate this causes memory fragmentation!!!!! | |
const wss = new WebSocketServer({ port: process.env.APP_PORT, perMessageDeflate: false }) | |
wss.on('connection', (ws, req) => { | |
ws.on('message', (data) => { | |
// do something | |
}) | |
ws.on('close', () => { | |
// log close | |
}) | |
ws.on('error', (error) => { | |
console.log('error', error) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment