Connect websocket from nuxt return E_ROUTE_NOT_FOUND: Route not found GET /socket.io/

#1

hi i try to connect to adonis websocket from nuxt

in nuxt
import Vue from ‘vue’
import ws from ‘adonis-websocket-client’
const wsVuePlugin = function (Vue, url, options) { Vue.prototype.$io = ws(url, options) }
Vue.use(wsVuePlugin, ‘ws://localhost:3333’, {})

//index.vue
created() {
this.$io.channel(‘chat’).connect()
},

in adonis
start/socket.js

const Ws = use(‘Ws’)

Ws.channel(‘chat’, ({ socket }) => {

console.log(‘new socket joined %s’, socket.id)

})

but return 404 error not found route need help
example request

http://localhost:3333/socket.io/?EIO=3&transport=polling&t=Mc2w_yC

thx for help

0 Likes

#2

Hi! Here is an example for a socket plugin. And dont forget further work with vuex plugins.

0 Likes