title: Socket.io Node - React connection false
body: <p>I'm not able to connect to socket on client for some reason. Logging socket all the time returns False. I tried official Socket.io app and it is working fine.. Can anyone help and let me know what I'm missing here?</p>
  
  <p><strong>Server</strong></p>
  
  <pre><code>const app = require('express')()
  const http = require('http').Server(app)
  const io = require('socket.io')()
  
  const router = require('./router')
  
  const PORT = process.env.PORT || 8080
  
  io.on('connection', (socket) =&gt; {
      console.log('user connected');
  
      socket.on('disconnect', () =&gt; {
          console.log('user disconnected');
      })
  })
  
  app.use(router)
  
  app.listen(PORT, () =&gt; {console.log(`Server running on port ${PORT}`)})
  </code></pre>
  
  <p><strong>Client</strong></p>
  
  <pre><code>import queryString from 'query-string'
  import io from 'socket.io-client'
  
  let socket;
  
  const Chat = () =&gt; {
      const ENDPOINT = 'http://localhost:8080'
      useEffect(() =&gt; {
          socket = io(ENDPOINT)
          console.log(socket);
  
      })
  
      return (
          &lt;div&gt;
              Chat
          &lt;/div&gt;
      )
  }
  
  export default Chat
  </code></pre>
  
  <p><strong>Solution</strong></p>
  
  <p>Server is listening on app instead http.listen(...)</p>