apache / apache/iotdb-client-csharp
最新的2.0.8版本在linux中会出现Name or service not known错误
- Langage dominant
- C#
- Étoiles
- 24
- Forks
- 6
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
升级2.0.8版本后linux系统上的连接出现问题,报错:Error occurs when opening session pool. Client pool size is not equal to the expected size. Client pool size: 0, expected size: 1, Please check the server status
但是windows上的连接没有问题。
通过日志发现如下错误:
warn: IoTDB[0]
Failed to create connection 1/1 to 192.168.1.10:6667
Thrift.Transport.TTransportException: Name or service not known
---> System.Net.Sockets.SocketException (00000005, 0xFFFDFFFF): Name or service not known
at System.Net.Dns.GetHostEntryOrAddressesCore(IPAddress address, Boolean justAddresses, AddressFamily addressFamily, Nullab>
at System.Net.Dns.GetHostEntry(String hostNameOrAddress, AddressFamily family)
at Thrift.Transport.Client.TSocketTransport..ctor(String host, Int32 port, TConfiguration config, Int32 timeout)
--- End of inner exception stack trace ---
at Thrift.Transport.Client.TSocketTransport..ctor(String host, Int32 port, TConfiguration config, Int32 timeout)
at Apache.IoTDB.SessionPool.CreateAndOpen(String host, Int32 port, Boolean enableRpcCompression, Int32 timeout, Boolean use>
at Apache.IoTDB.SessionPool.Open(CancellationToken cancellationToken)
检查发现Apache.IoTDB.SessionPool.CreateAndOpen调用了public TSocketTransport(string host, int port, TConfiguration config, int timeout = 0),这个构造函数直接调用了Dns.GetHostEntry去解析IP地址。
.NET 的 Dns.GetHostAddresses/GetHostEntry 最终依赖底层操作系统的名称解析 API;不同平台的行为并不完全一致。
在linux中 Dns.GetHostEntry(string) 遇到 IP 字符串时,不是简单返回这个 IP,而是会:
先把字符串解析成 IP;
对这个 IP 做一次反向解析拿主机名;
再用这个主机名做一次正向解析拿地址列表。
这个过程中任一步失败,都可能抛 SocketException。
在windows中则会宽松很多。
我现在把我的ip地址写道了/etc/hosts中,定义了一个主机名,现在可以正常连接。
但是这在linux中还是很不友好的,建议不要调用public TSocketTransport(string host, int port, TConfiguration config, int timeout = 0),而是使用public TSocketTransport(string hostNameOrIpAddress, int port, bool connectClient, TConfiguration config, int timeout = 0)代替,这个构造函数先判断hostNameOrIpAddress是不是IP地址,是的话直接使用,不是的话再调用Dns.GetHostEntry,这样linux系统就不用定义主机名了。
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Commencez par Apache.IoTDB.SessionPool.CreateAndOpen et inspectez le constructeur de TSocketTransport qu’il utilise, puis comparez les surcharges décrites dans l’issue. Reproduisez la connexion avec une adresse IP sous Linux et vérifiez que le pool de sessions s’ouvre sans nécessiter de nom d’hôte dans /etc/hosts, tout en préservant les connexions par nom d’hôte.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- csharp
- Domaine
- networking
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 64/100