0

I currently have a Python Flask SocketIO application that will be connecting to a Vue app using this socket.io library. The Vue app (currently) will poll the Python application using socket.io on a button press. I can correctly receive the data sent from Vue; however, Vue is not receiving the data. Currently, my actions/mutations looks like this:

const actions = {
  fbCommentsPerPost: (context) => {
    console.log('fb comments per post sent!')
    socket.emit('fb comments per post', { post_id: '123' })
    // socket.on('data', function (resp) {
    //   console.log(resp)
    // })
  },
  socket_connectResp: (context, message) => {
    console.log(message)
  },
  socket_fbData: (context, message) => {
    console.log(message)
  }
}

// mutations
const mutations = {
  SOCKET_FB_DATA: (state, status) => {
    console.log('comments!!!!')
  }
}

Using the README for this project, the socket_fbData should be receiving the data from the Python app (the backend is emitting 'fb data'). When I run a simple client in node using socket.io-client, this works and I can properly receive data. Moreover, when I uncomment the socket.on block in fbCommentsPerPost, I can at least console log the data. Is there something I'm missing here?

Cœur
  • 37,241
  • 25
  • 195
  • 267
xtheking
  • 575
  • 2
  • 8
  • 31

1 Answers1

1

vue-socket.io has an issue with converting socket events to actions and mutations. It kind of works but not as expected. Check issue #117

A few months ago there was few PRs with a fix for this issue but some edge cases are not covered. So you can try the latest version or just move to vue-socket.io-extended instead.

Max Liashuk
  • 1,043
  • 7
  • 18