title: Unable to connect to NodeJS standalone socket.io with ReactJS
body: <p>I am looking for the best WS solution for IoT project. I am currently testing my options with Web Sockets. I have tried so far two NPM libraries 'ws' and 'websockets'. They worked great both NodeJS and ReactJS implementation was simple. I am now trying websocket.io. Reading the documentation I struggle to create even a simple working example copying the code directly from the documentation. Since the test code is so simple, I am really confused especially after the positive experience with two previous packages. I am pretty sure I am doing something wrong but I am unable to spot my mistake. I am really thankful for anyone helping to spot what am I not doing right.</p>
  <p>NodeJS server instance listening on port 8000 (based on example here: <a href="https://socket.io/docs/v4/server-initialization/" rel="nofollow noreferrer">https://socket.io/docs/v4/server-initialization/</a>) :</p>
  <pre><code>const io = require(&quot;socket.io&quot;)();
  
  io.on(&quot;connection&quot;, socket =&gt; { 
     console.log('blip')
  });
  
  io.listen(8000);
  </code></pre>
  <p>React client trying to connect to the NodeJS server from port 2000:</p>
  <pre><code>import React from &quot;react&quot;;
  import { io } from &quot;socket.io-client&quot;;
  
  
  class Io extends React.Component {
  
  state = {
     wsConnected: false
  }
  
  componentDidMount() {
    const socket = io.connect('http://localhost:8000');
    socket.on(&quot;connect&quot;, () =&gt; {
      console.log('connect',socket.id); 
    });
  }
  
  render() {
     const { wsConnected } = this.state;
     return (
       &lt;div&gt;{wsConnected ? 'on' : 'off'}&lt;/div&gt;
     )
  }
  
  }
  
  export default Io
  </code></pre>