Fix port conflict between RQLite and LibP2P

CRITICAL FIX: Separate RQLite and LibP2P ports to prevent service startup failures

Changes:
- LibP2P now uses port 4000 (was conflicting with RQLite on 4001)
- RQLite continues to use port 4001 for HTTP API
- RQLite Raft uses port 4002
- Updated bootstrap peer configurations to use port 4000
- Updated install script port configurations
- Fixed firewall configuration to allow correct ports

This resolves the 'bind: address already in use' error that was preventing
the debros-node service from starting properly.
This commit is contained in:
johnysigma 2025-08-06 08:44:23 +03:00
parent cc276ccc22
commit 089916b5dd
4 changed files with 9 additions and 10 deletions

View File

@ -48,8 +48,8 @@ func main() {
}
}
// All nodes use port 4001 for consistency
port := 4001
// LibP2P uses port 4000, RQLite uses 4001
port := 4000
// Create logger with appropriate component type
var logger *logging.StandardLogger

View File

@ -18,8 +18,8 @@ var (
// BootstrapAddresses are the full multiaddrs for bootstrap nodes
BootstrapAddresses []string
// BootstrapPort is the default port for bootstrap nodes
BootstrapPort int = 4001
// BootstrapPort is the default port for bootstrap nodes (LibP2P)
BootstrapPort int = 4000
)
// Load environment variables and initialize bootstrap configuration
@ -95,8 +95,8 @@ func setDefaultBootstrapConfig() {
"12D3KooWGbdnA22bN24X2gyY1o9jozwTBq9wbfvwtJ7G4XQ9JgFm",
}
BootstrapAddresses = []string{
"/ip4/57.129.81.31/tcp/4001/p2p/12D3KooWJvJj94TmNwG1sntDWgAXi7MN3xxLLkoQzgHX6gQ22eKi",
"/ip4/38.242.250.186/tcp/4001/p2p/12D3KooWGbdnA22bN24X2gyY1o9jozwTBq9wbfvwtJ7G4XQ9JgFm",
"/ip4/57.129.81.31/tcp/4000/p2p/12D3KooWJvJj94TmNwG1sntDWgAXi7MN3xxLLkoQzgHX6gQ22eKi",
"/ip4/38.242.250.186/tcp/4000/p2p/12D3KooWGbdnA22bN24X2gyY1o9jozwTBq9wbfvwtJ7G4XQ9JgFm",
}
} else {
// Development: only use localhost bootstrap
@ -104,10 +104,10 @@ func setDefaultBootstrapConfig() {
"12D3KooWBQAr9Lj9Z3918wBT523tJaRiPN6zRywAtttvPrwcZfJb",
}
BootstrapAddresses = []string{
"/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWBQAr9Lj9Z3918wBT523tJaRiPN6zRywAtttvPrwcZfJb",
"/ip4/127.0.0.1/tcp/4000/p2p/12D3KooWBQAr9Lj9Z3918wBT523tJaRiPN6zRywAtttvPrwcZfJb",
}
}
BootstrapPort = 4001
BootstrapPort = 4000
}
// extractPeerIDFromMultiaddr extracts the peer ID from a multiaddr string

View File

@ -58,7 +58,6 @@ func NewNode(cfg *config.Config) (*Node, error) {
func (n *Node) Start(ctx context.Context) error {
n.logger.ComponentInfo(logging.ComponentNode, "Starting network node",
zap.String("data_dir", n.config.Node.DataDir),
zap.String("type", "bootstrap"),
)
// Create data directory

View File

@ -15,7 +15,7 @@ NOCOLOR='\033[0m'
INSTALL_DIR="/opt/debros"
REPO_URL="https://git.debros.io/DeBros/network.git"
MIN_GO_VERSION="1.19"
NODE_PORT="4001"
NODE_PORT="4000" # LibP2P port for peer-to-peer communication
RQLITE_PORT="4001" # All nodes use same RQLite port to join same cluster
RAFT_PORT="4002" # All nodes use same Raft port
UPDATE_MODE=false