The library does not support this function, you can check the token on every desired io socket event.
In the Github Issue, the author answered this analogy:
Id_token is like your national passport, both have an expiration date, you can enter the country if your passport has not expired and most countries will not track the expiration date to track you down.
You can handle this manually using socketio middleware, for example:
const timer = require('long-timeout')
function middleware (socket, next) {
const decodedToken = socket.user
if (!decodedToken.exp) {
return next()
}
const expiresIn = (decodedToken.exp - Date.now() / 1000) * 1000
const timeout = timer.setTimeout(() => socket.disconnect(true), expiresIn)
socket.on('disconnect', () => timer.clearTimeout(timeout))
return next()
}
source
share