我希望能够在 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# - Apache 点燃,C# : Thin Client unable to connect to server node,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64995996/