You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If socket has already connected through a valid token and token gets refresh after a while, the library still using the old token and that will cause 401 subscription_error on subscribe requests!
I'm experiencing this on socket.io adapter.
Any ideas on how solve this?
The text was updated successfully, but these errors were encountered:
I experience the same issue due to working with nuxt-auth + laravelJWT refresh scheme.
So dirty workaround for now it that I set actual access_token by settings actuall token on
mounted(){
this.$echo.options.auth.headers['Authorization'] = this.$auth.strategy.token.get()
... // logic to connect by $echo to channel
}
or better one I'm using right now:
plugin: axios.js
export default function ({ app, $axios }) {
$axios.onRequest(
async request => {
try {
if (app.$auth.strategy.token.status().expired()) {
await app.$auth.refreshTokens()
}
// set the Authorization header using the access token fetched from login config
const actualAuthToken = app.$auth.strategy.token.get()
request.headers['Authorization'] = actualAuthToken
app.$echo.options.auth.headers['Authorization'] =
actualAuthToken
app.$auth.strategy.token.sync()
} catch (e) {
console.error(e)
}
return request
},
error => {
return Promise.reject(error)
}
)
}
If socket has already connected through a valid token and token gets refresh after a while, the library still using the old token and that will cause
401 subscription_error
on subscribe requests!I'm experiencing this on
socket.io
adapter.Any ideas on how solve this?
The text was updated successfully, but these errors were encountered: