adonis-websocket-protocol icon indicating copy to clipboard operation
adonis-websocket-protocol copied to clipboard

Documentation example does not work

Open danilloalvis opened this issue 6 years ago • 4 comments

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

danilloalvis avatar Nov 25 '18 02:11 danilloalvis

Hey @danilloalvis! 👋

Can you please try with the official client instead of a Chrome extension?

RomainLanz avatar Nov 28 '18 09:11 RomainLanz

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?

joaopedroabreuu avatar Apr 13 '20 03:04 joaopedroabreuu

I have also same problem

usmanhafeez147 avatar May 28 '20 13:05 usmanhafeez147

Me too

alissin4444 avatar Jun 16 '20 03:06 alissin4444