Reputation: 1872
I'm using ws as the socket library for my node.js library.
so my question is, how can I reject a connection if the user doesn't pass the authorization process.
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({port: 6969});
wss.on('connection', function(socket){
// if the socket.upgradeReq.headers.cookie doesn't exists, reject the client
})
thanks a lot
Upvotes: 4
Views: 8704
Reputation: 203359
You can either use socket.close()
or socket.terminate()
to close the connection.
Upvotes: 4