net.corda.client.rpc.RPCException:无法连接到服务器。尝试过所有可用的服务器

问题描述 投票:0回答:1

OS:Windows 10和Ubuntu 18.04

Corda:4.4

我想学习CordaRPCOps,所以我首先使用了template’s Cordform deployNodes任务,该任务为我提供了三个正在运行的节点。

首先,我使用以下在本地运行的代码连接到PartyA的Corda节点。

NetworkHostAndPort nodeAddress = new NetworkHostAndPort("localhost", 10006);
CordaRPCClient client = new CordaRPCClient(nodeAddress);
CordaRPCConnection connection = client.start("user1", "test");
CordaRPCOps cordaRPCOps = connection.getProxy();

效果很好。

然后我尝试通过以下更改从同一网络上的另一台PC连接:

NetworkHostAndPort nodeAddress = new NetworkHostAndPort("192.168.1.149", 10006);

此操作失败,并出现以下错误:

net.corda.client.rpc.RPCException: Cannot connect to server(s). Tried with all available servers.

假设这与网络有关,我回到本地PC并运行相同的代码:

NetworkHostAndPort nodeAddress = new NetworkHostAndPort("192.168.1.149", 10006);

这也失败了。因此,我决定尝试使用PC名称而不是IP地址。这在本地和另一台PC上均失败。

corda
1个回答
0
投票

如果node.conf文件中的rpcSettings使用“ localhost”:

rpcSettings {
    address="localhost:10006"
    adminAddress="localhost:10046"
}

…您不能使用“ localhost”或“ 127.0.0.1”之外的任何东西连接到节点。

NetworkHostAndPort nodeAddress = new NetworkHostAndPort("localhost", 10006);

这也意味着您无法通过网络连接到该节点。

如果将“ localhost”替换为IP地址或计算机名称:

rpcSettings {
    address="192.168.1.149:10006"
    adminAddress="localhost:10046"
}

…然后,您可以在本地或通过网络上的另一台PC通过IP或计算机名称引用该节点:

NetworkHostAndPort nodeAddress = new NetworkHostAndPort("192.168.1.149", 10006);

当它们启动并列出各自的信息时,您会在Node Shell的打开屏幕上注意到更改。

--- Corda Open Source 4.4 (21e8c4f) -------------------------------------------------------------


Logs can be found in                    : F:\corda\Java\cordapp-template-java\build\nodes\PartyA\logs
! ATTENTION: This node is running in development mode!  This is not safe for production deployment.
Jolokia: Agent started with URL http://127.0.0.1:7006/jolokia/
Advertised P2P messaging addresses      : localhost:10005
RPC connection address                  : 192.168.1.149:10006
RPC admin connection address            : localhost:10046
© www.soinside.com 2019 - 2024. All rights reserved.