Vue Socket Connection Not Triggered

I am trying to use vue in combination with sockets. However I cannot seem to get the vue application to accept socket events. I am following the tutorials found online and they tell me that the example below should work. However it doesn't and I am puzzle why.

What I do know:

  • The sockets are connected. The server side triggeres the connection event
  • I can emit an event from app.vue by using this.$socket.emit('mounted', 'something')
  • I cannot received events under the sockets section. None of the connect, disconnect or test are triggered.

Why is the sockets part not working?

My server.js:

const io  = require('')(8000);
io.on('connection', function(socket) {
  console.log(`A user connected with socket id ${}`)

  socket.on('mounted', function(data) { 
  console.log('data', data)

  socket.on('disconnect' , function(){
    console.log('User left page');

my main.js

import Vue from 'vue'
import App from './App.vue'
import VueSocketIO from ''
import SocketIO from ""

Vue.config.productionTip = false

Vue.use(new VueSocketIO({
  debug: true,
  connection: SocketIO('http://localhost:8000'), 

new Vue({
  render: h => h(App),

the script in my app.vue

import HelloWorld from './components/HelloWorld.vue'
//var socket = io();

export default {
  name: 'App',
  components: {
  mounted () {
    this.$socket.emit('mounted', 'something')
  sockets : {
    test: function(data){
      console.log('test triggered', data)
    connect() {
    disconnect() {
            console.log("server disconnected");


If you are running a version greater than 3.0.7 you need to uninstall and install version 3.0.7 instead.

I had this exact problem and upon inspecting the NPM page I saw that they had released 2 new updates (3.0.8 and 3.0.9). I was running 3.0.9 in my project. I uninstalled the 3.0.9 version and installed the 3.0.7 version which worked immediately without changing any code. My other project where did work was running version 3.0.7 as well.

I am not sure if I did something wrong on my end but I followed the exact documentation of their newer version and I couldn't make it work. So for now I assume it is an error on their end.