Integrating with Adonis 4


Hello ,
I want to use web socket in Adonis 4 but the official WS is under development.
So the only way for using it (at this time) is integrating with adonis 4 . I tried to use adonis-websocket and change it to work on 4th version but I could not find http.js .
How can I use adonis-websocket on adonis4? or maybe apply this “” on adonis 4?

Kind Regards


Create start/socket.js file and paste following code inside it.

const Server = use('Server')
const io = use('')(Server.getInstance())

io.on('connection', function (socket) {

websocket with adonis 4

Thanks @virk , It worked but now I want to connect adonis 4 to adonis-websocket ( for using auth & … .
I change some parts (ex. some changes on requires and setting @adonis/… ) but now I have a problem:

TypeError: Class extends value #<SessionManager> is not a constructor or null
    at new Ws (/*********/node_modules/adonis-websocket/src/Ws/index.js:24:29)

I tried some online solutions but I could not solve the problem.
What can I do?

Kind Regards.


adonis-websocket is not compatible with 4.0


I know that . I want to make it compatible. now It works if I remove :

class WsSession extends Session {

from line 24-25 of Ws/index.js but if I remove it , Auth and session will not work.

Could you please help me to solve this issue and publish it?

Kind Regards


Hi virk,
Have you news about websocket integration in Adonis 4? I am still work in new project and I have choose your framework and nuxt for the client.
My project is a “Registered Electronic Mail” organizer, multi tenant, multi mailbox and with user role permission. I think that when I finish I want publish a complete video lessons to bring Adonis and developer. Your project is great and before or after I support you on patreon. Best regards.


Hi Virk, I follow but it does not run.


Did you tried building the connection from the browser?


Tks, i did it.
Now, I want to use in the ‘controller’ how?


thanks , is webSocket going to be developed in near future ? it would be awesome if it was developed (i realy hate to go back on other frameworks like express (i’m Addicted tp adonis :smile: ) )


Yes, it is.