There are separate nodejs applications running in the docker. There are separately working angular2 applications (docker -> nginx). The connection between them occurs with the help of ip & nginx-config.

Now the question is: is it possible to associate the socket.io with a nodejs server that is even on another machine (physically)?

I understand that there are many examples of working Angular2 & Nodejs + Socket.io. However, they all work on the same machine (in the same nodejs application). Is it possible to connect a client to a nodejs server (located on different machines) using socket.io?

  • And how do you configure the connection with the socket on the client. Its address, port is also written there. - Vasily Barbashev
  • Yes, I agree. Like this: this.socket = io (' localhost: 8000' ); However, they are on the same computer. Will they work on different computers? - Denis Adamenko
  • To nodejs-application on one, and angular2 on the other - Denis Adamenko
  • And what's the difference) The address is the address, it will knock where you say. The main thing that the domain access rights were, such as allow-control-allow-origin - Vasily Barbashev
  • Now I will try to accomplish my goal. Thanks for the replies - Denis Adamenko

1 answer 1

The answer to this question is extremely simple? You can really work with socket.io on different machines. The main thing is to correctly register the address and port. Example:

 this.socket = io('http://localhost:8000'); this.socket.on('message', function(data){ alert(data); }.bind(this));