Vue-Socket.io icon indicating copy to clipboard operation
Vue-Socket.io copied to clipboard

socket.io V3

Open mcorning opened this issue 4 years ago • 8 comments

Will vue-socket work with socket.io V3?

mcorning avatar Nov 12 '20 22:11 mcorning

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

dbussert avatar Nov 14 '20 22:11 dbussert

Excellent. Thanks for the reply.

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


From: Dillon Bussert [email protected] Sent: Saturday, November 14, 2020 2:46:16 PM To: MetinSeylan/Vue-Socket.io [email protected] Cc: Michael Corning [email protected]; Author [email protected] 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.

mcorning avatar Nov 15 '20 03:11 mcorning

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

Tzahile avatar Jan 12 '21 14:01 Tzahile

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;
        }

dbussert avatar Jan 12 '21 15:01 dbussert

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

djcaesar9114 avatar Feb 23 '21 07:02 djcaesar9114

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/

leonardlin avatar Apr 17 '21 11:04 leonardlin

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 });

SelimAydi avatar May 07 '21 11:05 SelimAydi

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

liquidvisual avatar Sep 09 '21 11:09 liquidvisual