Websocket Auth Middleware returns Invalid session


I’ve configured everything according to the docs, works without the auth middleware.


authenticator: 'session',


Ws.channel('chat', 'ChatController').middleware(['auth'])


const globalMiddleware = [

const namedMiddleware = {
  auth: 'Adonis/Middleware/Auth'


Added to app.js > providers


Would really appreciate some help because I’ll be using Adonis + web-sockets in a production application soon! :smile:


Oh, just found the solution. Thanks Virk!

Used instead of localhost.


I’m having the same issue and I have it setup the exact same way. However, I’m using nginx in my dev env and I’m using a subdomain.

const ws = Ws('ws://example.me') // Works, but auth invalid session
const ws=Ws('ws://app.example.me') // Websocket does not work

I’m guessing this is as @virk said and not working because the websocket connection URL and the Http host have to be the same. Is there a way to include the subdomain into the websocket URL?