Apache Ignite,C#:瘦客户端无法连接到服务器节点



我希望能够在C#中以编程方式配置一个在缓存中执行SQL查询的瘦客户端节点;此外,该节点与远程启动的集群连接。然而,我在本地VS控制台和Linux中都收到错误:

本地VS控制台错误

Apache.Ignite.Core.Client.IgniteClientException: 'Client connection has failed. Examine InnerException for details'
InnerException
SocketException: An established connection was aborted by the software in your host machine.

远程Linux错误

Unknown connection detected (is some other software connecting to this Ignite port? missing SSL configuration on remote node?) [rmtAddr=/[localHost2]]

我想知道问题是在我的瘦客户端配置的C#代码中,还是在我为启动远程集群而传递的XML文件中。

C#代码

namespace ThinClient
{
class Program
{
static void Main(string[] args)
{
var cfg = new IgniteClientConfiguration
{
Endpoints = new[] { "[remoteHost]", "[remoteHost]:47500..47509", "[remoteHost]:10800", "[localHost2]",  "[localHost2]:10800"}
};

using (var client = Ignition.StartClient(cfg))
{
var cache = client.GetOrCreateCache<int, Object>("default");
Console.WriteLine(">>> Client node connected.");
}

}
}
}

XML配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
<value>[remoteHost]:47500..47509</value>
<value>[localHost1]:47500..47509</value>
<value>[localHost2]:47500..47509</value>
<value>[localHost2]:10800</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</beans>

我怀疑问题的出现是因为您试图从localHost2连接到具有瘦客户端的发现端口。要解决此问题,只需从瘦客户端配置中删除发现终结点。

var cfg = new IgniteClientConfiguration
{
Endpoints = new[] { "[remoteHost]:10800" }
}; 

同样值得一提的是,您的服务器配置似乎也不正确。addresses属性应仅包含厚服务器节点的发现地址。至少提供一个工作节点的一个地址是可以的(如果一个节点将成为第一个,则甚至为0(。但通常建议提供所有这些配置,这样可以为每个服务器节点保留类似的配置。在你的情况下,这个片段应该做的技巧:

<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>[remoteHost]:47500..47509</value>
</list>
</property>
</bean>
</property>

最新更新