You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux下执行runExampleClientRPCJava任务失败:无法连接服务器

Answer

I’ve helped troubleshoot this exact issue many times with CorDapp developers—this is one of the most common RPC connection problems, and it almost always boils down to a few straightforward causes. Here’s a breakdown of what’s likely going wrong, how to fix it, and what other users have reported:

Common Causes & Fixes

1. Your CorDapp Node Isn’t Running (or Failed to Start)

The RPC client can’t connect if the target node isn’t up and listening for RPC requests.

  • Check if the node is running: Run ps aux | grep corda in your terminal—you should see a process for your CorDapp node.
  • Verify node startup: Check your node’s log file (usually in logs/node-<party-name>.log) for a line like Listening on address localhost:10006 for RPC connections. If you don’t see this, the node failed to start properly—look earlier in the logs for errors (like missing dependencies or misconfigured node.conf).
  • Restart the node: If it’s not running, start it with ./gradlew runNodes (from the project root) and wait for the "RPC listening" log line before running the client.

2. Mismatched RPC Address/Port Between Client & Node

The client might be trying to connect to the wrong port or address.

  • Check node’s RPC port: Open your node’s node.conf file and look for the rpcSettings section—this defines the address and port the node uses for RPC (default is localhost:10006 for PartyA).
  • Validate client configuration: Open java-source/src/main/java/com/example/client/ExampleClientRPC.java and check the CordaRPCClient initialization. Make sure the NetworkHostAndPort matches exactly what’s in your node’s rpcSettings. For example:
    // Correct example (matches default node config)
    CordaRPCClient client = new CordaRPCClient(new NetworkHostAndPort("localhost", 10006));
    
    A common mistake is using the node’s P2P port (usually 10005) instead of the RPC port.

3. Linux Firewall/Security Group Blocking the RPC Port

Linux firewalls (like ufw or firewalld) often block incoming/outgoing connections on non-standard ports like the CorDapp RPC port.

  • Test with firewall disabled: Temporarily stop your firewall to rule this out. For firewalld, run sudo systemctl stop firewalld; for ufw, run sudo ufw disable. Then try running the client again.
  • Allow the RPC port permanently: If this fixes the issue, add a rule to allow traffic on the RPC port. For firewalld:
    sudo firewall-cmd --add-port=10006/tcp --permanent
    sudo firewall-cmd --reload
    
    For ufw:
    sudo ufw allow 10006/tcp
    

4. Missing RPC Authentication Credentials

If your node is configured to require RPC username/password authentication, the client will fail to connect without providing these details.

  • Check node’s RPC user config: Look in node.conf for the rpcUsers section—this lists authorized users and their permissions.
  • Update client code to include auth: Modify the client’s start() call to include the username and password from node.conf:
    CordaRPCConnection connection = client.start("your-rpc-username", "your-rpc-password");
    

Community Context

Yes, this is a super common issue reported by CorDapp developers on community forums and Stack Overflow. Most users resolve it by:

  • Realizing they forgot to start their nodes before running the client
  • Fixing a port mismatch between client code and node config
  • Unblocking the RPC port in their Linux firewall

A few users also ran into issues where their node’s node.conf had typos in the rpcSettings section, causing the node to not bind to the expected RPC port. Always double-check that config file if you’ve ruled out the other causes!

内容的提问来源于stack exchange,提问作者C. Andrews

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 10:03:33