adonis-websocket-protocol
adonis-websocket-protocol copied to clipboard
Documentation example does not work
I'm learning to use WebSocket and I'm using adonis for this, I'm following the guide in the step-by-step documentation, but I could not make the chat work
documentation: https://adonisjs.com/docs/4.1/websocket
eu instalei o: @adonisjs/websocket
adonis install @adonisjs/websocket
I registered the 'wsServer()' inside server.js.
const providers = [
'@adonisjs/websocket/providers/WsProvider'
]
I registered the provider inside start/app.js.
const { Ignitor } = require('@adonisjs/ignitor')
new Ignitor(require('@adonisjs/fold'))
.appRoot(__dirname)
+ .wsServer()
.fireHttpServer()
.catch(console.error)
I registered the 'chat' channel within 'start/socket.js' and make the Chatcontroller
const Ws = use('Ws')
Ws.channel('chat', 'ChatController')
I also tried
Ws.channel('chat', function ({ socket }) {
console.log(socket.topic)
// will always be `chat`
})
but when I try to access WebSocket I have no answer, I have already tried with 'ws://localhost:3333' 'ws://localhost:3333/chat'
but I just had success accessing 'ws://localhost:3333/adonis-ws'
I used this extension to test: https://chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo
Hey @danilloalvis! 👋
Can you please try with the official client instead of a Chrome extension?
I also tried the same thing and even then it didn't work ... I followed all the steps on this link: https://adonisjs.com/docs/4.1/websocket
Any idea what it might be?
I have also same problem
Me too