SocketCluster / socketcluster

Highly scalable realtime pub/sub and RPC framework
https://socketcluster.io
MIT License
6.15k stars 314 forks source link

socket.on is not a function #588

Closed sahul360 closed 1 year ago

sahul360 commented 1 year ago

I am getting this error while I was doing the below steps in my reactJS application

const socketClusterConfig = { port: 8000, hostname: 'localhost' };

const socket = socketCluster.create(socketClusterConfig); 

socket.on('connect', () => {
  console.log('Connected to SocketCluster server');
});
maarteNNNN commented 1 year ago

What's your client version?

sahul360 commented 1 year ago

"socketcluster-client": "^17.1.0"

maarteNNNN commented 1 year ago

You can track connection events on the client via:

(async () => {
  for await (const event of socket.listener('connect')) {
    console.log('Connected to server', event);
  }
})();