socketcluster icon indicating copy to clipboard operation
socketcluster copied to clipboard

Comunicate between servers

Open tarilo opened this issue 7 years ago • 7 comments

We try to comunicate betweeen servers with scServer.exchange.subscribe. When run in one machine with x brokers all works fine but we now mount a horizontal cluster with x machines and ecah machine wirh x workers. All machines are conected to one state server and have a scc-broker. Now we can't use this method, have this error:

NoMatchingSubscribeTargetError: Could not find a matching subscribe target scc-broker for the channelControl channel - The scc-broker may be down

tarilo avatar Jul 11 '18 10:07 tarilo

Change the question, testing and testing we detect scServer.exchange.subscribe works perfect in one servers machine, if you mount a cluster with one state server, one scc brokers and x servers with brokers and server the comunication between machines dont work. The messages in origin machine works but other server dont receive nothing.

tarilo avatar Jul 11 '18 16:07 tarilo

@tarilo Long story short, it should be fixed in scc-state@6.1.0 Please, try to upgrade.

P.S. the 6.1.0 has been released just today, and the latest version in npm is still 6.0.3, the 6.1.0 will be pushed sometime soon, please, hang on.

MegaGM avatar Jul 11 '18 16:07 MegaGM

Hi @MegaGM We updated to scc-state 6.1.0 and can't connect from machines to the horizontal cluster. Launching 2 server on same server works fine but when add external machines, the state server show new conection but server reports this error and there is not connection between servers

{ SocketProtocolError: Socket hung up at SCClientSocket._onSCClose (/home/xxxx/xxxxxx/node_modules/scc-broker-client/node_modules/socketcluster-client/lib/scclientsocket.js:647:15) ..... name: 'SocketProtocolError', message: 'Socket hung up', code: 1006 }

tarilo avatar Jul 13 '18 11:07 tarilo

Hi @MegaGM . Investigating we found the problem. All the machines need to have a local scc-broker running to woth with hotizontal cluster. Any code try to connect to 127.0.0.1 or localhost. If you run local scc-broker on each server all works good. The problem is your architecture picture are not correct.

tarilo avatar Jul 17 '18 07:07 tarilo

@tarilo It shouldn't be the case. There are several companies running each instance in the SCC cluster on a separate machine in production without issues.

It probably means that your scc-worker (regular) instances cannot find the correct IPs of your scc-broker instances. Maybe the port is blocked or the IP address of the machine is not publicly accessible or maybe the container port mapping is wrong or maybe because the scc-broker is running inside a container, it's passing its private container IP instead of the public IP address.

Note that you can configure the external IP address of the scc-broker instance by passing an SCC_INSTANCE_IP environment variable to the instance/container. See https://github.com/SocketCluster/scc-broker/blob/master/server.js#L9

jondubois avatar Jul 17 '18 10:07 jondubois

Hi @jondubois all the servers are in the same network on google cloud. firewall has open ports. We need to run one scc-broker on each machine to setup cluster working. The parameters you say are in the scc-broker, i need to pass the scc-broker ip to the sc-server to reach the scc-broker. Setup x workers, one broker and one scc-brokers on each machine works fine. Thanks

tarilo avatar Jul 17 '18 10:07 tarilo

@tarilo You shouldn't need to pass the IP of the scc-broker to regular instances, you just need to tell the scc-broker its own external IP address when you run it and it will tell the scc-state instance and then the scc-state instance will tell every other instance. But I guess whatever works.

jondubois avatar Jul 17 '18 11:07 jondubois