title: How to set up socket connection URL for production server?
body: <p>I am deploying to production my MEAN stack app, I have a sockets module for real-time notifications. However, while checking for errors in <code>www.example.com</code> i saw this error <code>POST http://www.example.com/socket.io/?EIO=3&amp;transport=polling&amp;t=MgkPNGk 404 (Not Found)</code></p>
  
  <p>My code works as intended in development when I try to connect to <code>localhost:4444</code> which is the port I am using for socket communication with my server.
  However, in production, I can't connect my server and my client.
  I already tried different ways to achieve this with something like </p>
  
  <pre><code>private socket = io(window.location.hostname + ':4444') 
  private socket = io('http://www.example.com') 
  private socket = io('http://www.example.com:4444') 
  </code></pre>
  
  <p>But none of this seems to work. Is there something I am missing? I am sure this is just a syntax mistake but could anyone provide me an example of how to achieve this?</p>
  
  <p>// Client code</p>
  
  <pre><code>import * as io from 'socket.io-client';
  
  @Injectable({providedIn: 'root'})
  export class SocketService
  {
      private socket = io(window.location.hostname) 
      // private socket = io('http://localhost:4444') &lt;- this works in development and I cant find a solution to do it in production,
      constructor(@Inject(DOCUMENT) private document,
                  private http: HttpClient){
                      console.log(window.location.hostname)
                  }
  }
  </code></pre>
  
  <p>//Server code</p>
  
  <pre><code>var server   = http.createServer(app);
  var io       = require('socket.io').listen(server);
  var socketHelper = require('./helpers/socketHelper')(io)
  server.listen(4444)
  </code></pre>