MetinSeylan / Vue-Socket.io

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

socket.io V3 #292

Open mcorning opened 3 years ago

mcorning commented 3 years ago

Will vue-socket work with socket.io V3?

dbussert commented 3 years ago

3.x seems to be working fine for my use case

mcorning commented 3 years ago

Excellent. Thanks for the reply.

Sent from Samsung tablet Get Outlook for Androidhttps://aka.ms/ghei36


From: Dillon Bussert notifications@github.com Sent: Saturday, November 14, 2020 2:46:16 PM To: MetinSeylan/Vue-Socket.io Vue-Socket.io@noreply.github.com Cc: Michael Corning mcorning@outlook.com; Author author@noreply.github.com Subject: Re: [MetinSeylan/Vue-Socket.io] socket.io V3 (#292)

3.x seems to be working fine for my use case

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/MetinSeylan/Vue-Socket.io/issues/292#issuecomment-727276007, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABYY7LQ2BHUV5BE3PHHXX53SP4CDRANCNFSM4TT3A5VQ.

Tzahile commented 3 years ago

3.x seems to be working fine for my use case

@dbussert Could you please share what is required for migration? I tried migrating but the client refuses to connect to the server

dbussert commented 3 years ago

I have a working system with the latest of all libraries. This is generally what you need.

client

package.json

"socket.io-client": "",
"vue-socket.io": "",

main.js

import VueSocketIO from 'vue-socket.io'
import SocketIO from "socket.io-client"
...
Vue.use(new VueSocketIO({
    debug: true,
    connection: SocketIO(`/`, {
        path: '/socket'
    })
}))

App.vue

  sockets: {
    async message(message) {
       //handle message
    }
  },

server

package.json

"socket.io": "",

express web server

const io = require('socket.io')(http, { path: '/socket' })
...
io.emit('message', json)

nginx

        location /socket/ {
            proxy_pass http://your-express-server;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header Host $host;
        }
djcaesar9114 commented 3 years ago

Actually it doesn't work perfectly, look at all the warnings you get in the compilations and during the execution in the console.

leonardlin commented 3 years ago

It doesn't work for me out of the box. this library is using socket-io v2

socket-io v3+ servers probably need to set backward compatibility, otherwise it doesn't work https://socket.io/blog/socket-io-3-1-0/

SelimAydi commented 3 years ago

It doesn't work for me out of the box. this library is using socket-io v2

socket-io v3+ servers probably need to set backward compatibility, otherwise it doesn't work https://socket.io/blog/socket-io-3-1-0/

Like @leonardlin said, compatibility mode (allowEIO3: true) is available between a Socket.IO v2 client and a Socket.IO v3 or v4 server.

On the server side: const io = require("socket.io")({ allowEIO3: true });

liquidvisual commented 3 years ago

Has anyone gotten this to work with the Vue 3 composition API?