Answer the question
In order to leave comments, you need to log in
How to reconnect to server using vue-socket.io?
Good day.
Trying to build a web app with vue.js? in which on the same page, depending on the value of the variable, either the application interface or the login window will be displayed. The application uses socket.io on the server side and vue-socket.io on the client side.
The problem is this - when the page is initially loaded, vue-socket.io tries to connect to the server, which in turn checks for the existence of a session and if it does not exist, it refuses to connect. After entering the username and password, a session is created, but it is not possible to start a second attempt to connect to the server.
Tried various vue-socket.io commands like - this.$socket.connect(), this.$socket.emit('message'), this.$socket.open(). But nothing happens. At the same time, if you refresh the page, then, accordingly, vue-socket.io makes a new request to the server, which ends in success and the application interface opens.
The initial connection is made in the following way:
import VueSocketio from 'vue-socket.io';
Vue.use(VueSocketio, '/', store);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question