I am trying to connect web3j object to the mainnet using geth. I can't use infura because i am working with replay transaction observable function which doesn't work with infura. To connect with the testnet we use port 8545, what port number should we use to connect to the mainnet. Also, is it necessary that all the blockchain should be allowed to synchronize before I start using the mainnet?
You can run
geth with any port you like, and connect with
web3j to that port. The network
geth connects to is not defined by the port it exposes for
API AND CONSOLE OPTIONS: --rpc Enable the HTTP-RPC server --rpcaddr value HTTP-RPC server listening interface (default: "localhost") --rpcport value HTTP-RPC server listening port (default: 8545)
so you can use the same 8545 as for mainnet or, if you like, establish your own internal convention and always run
geth with another port, like
8747, when connecting to testnet.