Apache Ignite,C#:瘦客户端无法连接到服务器节点
Apache Ignite, C#: Thin Client unable to connect to server node
我希望能够在 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>
我希望能够在 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>