How to connect multiple sockets in a single vuejs project?

629 views Asked by At
import VueSocketIOExt from 'vue-socket.io-extended';
import { io } from 'socket.io-client';

const socket = io('http://localhost:3200/');
const socket1 = io('http://localhost:3100/');

Vue.use(VueSocketIOExt, socket);
Vue.use(VueSocketIOExt, socket1);

I tried using the above code. But only only socket is working. Is it possible to connect both the sockets simultaneously.

1

There are 1 answers

1
kissu On

Vue.use(VueSocketIOExt, socket1) is probably overriding Vue.use(VueSocketIOExt, socket), hence only the last one is taking into account IMO.

What if you try the following?

Vue.use(VueSocketIOExt, socket)
Vue.use(VueSocketIOExt2, socket1)