scc-state icon indicating copy to clipboard operation
scc-state copied to clipboard

Bind to a specific IP?

Open perpetual-hydrofoil opened this issue 7 years ago • 1 comments

Is it possible to specify an IP as an env var, a passed argument to node server, etc to bind to for scc-state, scc-broker, etc?

I think this is what I'm looking for in scc-broker, but it doesn't seem to have a parallel in scc-state: https://github.com/SocketCluster/scc-broker/blob/master/server.js#L9

Without binding to a specific IP, there's no way to take advantage of TUN/TAP virtual devices for encrypted networking (or preventing external access).

perpetual-hydrofoil avatar Jan 02 '19 04:01 perpetual-hydrofoil

@jamiesonbecker SCC_INSTANCE_IP is not the IP address on which the scc-broker server binds itself; it's the IP address which the scc-broker uses to advertise itself to the cluster; so other instances will use this IP address when they want to connect to the scc-broker; it's mostly used when running the instance inside a container to allow it to be referenced by others using a single consistent public IP.

It sounds like what you need is something like the host param which is passed to the Node.js tcp/net server's listen function: https://nodejs.org/api/net.html#net_server_listen_port_host_backlog_callback

This feature is not currently exposed by any component of SCC (you could do it on scc-broker using SOCKETCLUSTER_OPTIONS env variable but it's tricky because it needs to be a JSON object).

PRs to expose this feature directly with a single env var would be welcome but it should be done consistently across both scc-state and scc-broker - Following naming conventions for env vars for different instance types.

jondubois avatar Jan 09 '19 09:01 jondubois