Connection closed before receiving a handshake response error

#1

I am using adonis ws client lib to connect to adonis ws server.

import Ws from '@adonisjs/websocket-client'

let adonisWs = Ws('ws://localhost:3333/', {
    path: 'path-in-socket-config-on-server'
  })
adonisWs.connect()

On server side, I registered Ws provider and added few channels inside start/socket.js

const Ws = use('Ws')
Ws.channel('User:*', 'UserController')

However, on client I don’t event subscribe to any topic, as it throws errors when on adonisWs.connect().

I did a couple of projects with adonis ws setup before, and it worked. Only difference is that now I import import Ws from ‘@adonisjs/websocket-client’, whereas before I added a script tag which proveded adonis global object with Ws on it (but I can’t get that to work inside nuxt, and this seems like better solution anyway)

When I put code above inside if(process.browser) i get the same error.

1 Like