MetinSeylan / Vue-Socket.io

😻 Socket.io implementation for Vuejs and Vuex
https://metin.sh
MIT License
3.95k stars 496 forks source link

Uncaught Error: Unsupported connection type #302

Closed lucahttp closed 2 years ago

lucahttp commented 3 years ago

Uncaught Error: Unsupported connection type at t.value (vue-socketio.js?5132:10) at new t (vue-socketio.js?5132:10) at eval (main.js?c6f4:35) at Module../src/pages/Home/main.js (index.js:1818) at webpack_require (index.js:849) at fn (index.js:151) at Object.2 (index.js:1855) at webpack_require (index.js:849) at checkDeferredModules (index.js:46) at index.js:925

image

im doing a proyect in my personal computer working ok also works fine in the server but when my colleague try to tun the same code get this error,

the web page are conected to the socket server in the cloud

quanghm27 commented 3 years ago

Check your params

https://github.com/MetinSeylan/Vue-Socket.io/blob/master/src/index.js#L53

lucahttp commented 2 years ago

thank you, its solved

SolberLight commented 1 year ago

Here's an example for future users : Express part :

const express = require('express')
const { Server } = require('socket.io')
const http = require('http')

const app = express()
const server = http.createServer(app)
const io = new Server(server, {
    cors: {
        origin: '*',
        methods: ['GET', 'POST', 'REMOVE']
    }
})
const PORT = process.env.PORT || 8080

io.on('connection', (socket) => {
    console.log('New socket user')
})

server.listen(PORT, () => { console.log(`Server started on port : ${PORT}`)})

Vuejs part :

import { createApp } from 'vue'
import App from './App.vue'
import VueSocketIO from 'vue-3-socket.io'
import SocketIO from 'socket.io-client'

const socketConnection = SocketIO('http://localhost:8080');

createApp(App)
    .use(new VueSocketIO({
        debug: true,
        connection: socketConnection,
    }))
    .mount('#app')