Starting slave in a fixed port (for firewall reasons)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Starting slave in a fixed port (for firewall reasons)

Ramakrishnan, Lakshmanan [Tech]
We want the master to connect to a fixed slave port. When we used –tcp option, slave started listing in arbitrary port and wrote it to the file and server connected to the file
 
This is the code we see in the Launcher
 
    private void runAsTcpServer() throws IOException, InterruptedException {
        // if no one connects for too long, assume something went wrong
        // and avoid hanging foreever
        ServerSocket ss = new ServerSocket(0,1);
        ss.setSoTimeout(30*1000);
 
        // write a port file to report the port number
        FileWriter w = new FileWriter(tcpPortFile);
        w.write(String.valueOf(ss.getLocalPort()));
        w.close();
 
        // accept just one connection and that's it.
        // when we are done, remove the port file to avoid stale port file
        Socket s;
        try {
            s = ss.accept();
            ss.close();
        } finally {
            tcpPortFile.delete();
        }
 
        runOnSocket(s);
    }
 
Which would mean the port number to start the slave is not configurable. So we started looking at –connectTo option but we are not sure how to use it.
 
Can anyone tell us how to start the slave at a fixed port or make the slave connect to a fixed port on the master (One side of the connection has to be constant so we can create a firewall rule)
 
Thanks
Lakshmanan