I have a Electron Client/Server Application where the Server Communicates with a couple of Clients over the LAN. This communication is established via node-ipc
.
The Problem is, that I have no control over the LAN DHCP. So at startup I have no idea of the Server IP, and to make it worse it may be that the Clients are ready before the Server even is started.
So my Server script is:
const NodeIpc = require('node-ipc');
NodeIpc.config.id = 'world';
NodeIpc.config.retry = 1500;
NodeIpc.config.networkHost = FunctionToReadIP();
NodeIpc.serveNet(
function () {
whatever();
});
And on the Client:
const NodeIPC = require('node-ipc');
NodeIPC.config.id = ClientID;
NodeIPC.config.retry= 1500;
NodeIPC.connectToNet(
'world',
function(){
NodeIPC.of.world.on(
'connect',
function(){
NodeIPC.of.world.emit('Data.fromClient',{data: ClientID});
}
);
});
As long as I test everything on one Machine it works great, but I cannot connect other Machines. I there any way the Server and Client can find each other as soon as they are started, without knowing who has which IP?
I haven't worked with
node-ipc
, but I'm pretty sure that for a client-server socket connection to be established, only the client needs to know the address of the server.There are multiple solutions to this. You can ...