verifyClient function or alternative #108
-
Hello, thanks for your library I followed an earlier version which had the option to check the client ... if the verification failed, called the const http = require('http')
const WebSocketServer = require('uws').Server
const PORT = proccess.env.PORT || 3000
const server = http.createServer((req, res) => {
// do stuff...
})
const WS = new WebSocketServer({
server: server,
verifyClient (info, cb) {
// for example ever fails
cb(false, 401, 'Unauthorized')
}
})
WS.on('connection', function(ws) {
// never show
console.log(ws)
ws.on('message', data => {})
ws.on('error', CloseEventCode => {})
})
server.listen(PORT) The connection was aborted before arriving at the event onconnection and in front-end show this in console: My question: is it possible to reproduce the same behavior in the current library? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
No, but you can close the websocket in the open handler if you don't find the http request suitable. |
Beta Was this translation helpful? Give feedback.
-
UpgradeAsync and UpgradeSync examples shows this feature now |
Beta Was this translation helpful? Give feedback.
UpgradeAsync and UpgradeSync examples shows this feature now