title: Socket.IO Broadcast emit not working how to fix it ,
body: <p>Hey there i'm trying to send message to everyone connected to the server that a new user is connected except the new user connect so i'm using socket.broadcast.emit() but it doesn't fire up in browser console</p>
  <p>my code :</p>
  <pre><code>const path = require('path')
  const http = require('http')
  const express = require('express')
  const socketio = require('socket.io')
  
  
  const app = express()
  const server = http.createServer(app)
  const io = socketio(server)
  
  const port = process.env.PORT || 3000
  const publicDirectoryPath = path.join(__dirname,'../public')
  
  app.use(express.static(publicDirectoryPath))
  
  io.on('connection',(socket)=&gt;{
      
      console.log('New web socket connection')
     
      socket.emit('welcome',&quot;Welcome !&quot;)
  
      socket.broadcast.emit('message','A new user has joined !')
  
    
  
      socket.on('sendMessage',(message)=&gt;{
          io.emit('messageSent',message)
      })
  
  })
  
  
  server.listen(port,()=&gt;{
      console.log('Server is up on 3000')
  })
  </code></pre>