From 6b4e2a89ffa4f0b866ba8078868b45d2c4eea6d7 Mon Sep 17 00:00:00 2001 From: RomanTerentev Date: Fri, 17 Apr 2020 04:43:52 +1000 Subject: [PATCH] [doc] Improve authentication example (#1741) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 196455562..3a23aed9d 100644 --- a/README.md +++ b/README.md @@ -266,8 +266,10 @@ wss.on('connection', function connection(ws, request, client) { }); server.on('upgrade', function upgrade(request, socket, head) { + // This function is not defined on purpose. Implement it with your own logic. authenticate(request, (err, client) => { if (err || !client) { + socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n'); socket.destroy(); return; }