diff --git a/src/Apache.IoTDB/SessionPool.cs b/src/Apache.IoTDB/SessionPool.cs index 8d42282..971a0d7 100644 --- a/src/Apache.IoTDB/SessionPool.cs +++ b/src/Apache.IoTDB/SessionPool.cs @@ -21,6 +21,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Net; using System.Security.Cryptography.X509Certificates; using System.Threading; using System.Threading.Tasks; @@ -450,9 +451,19 @@ public async Task GetTimeZone() private async Task CreateAndOpen(string host, int port, bool enableRpcCompression, int timeout, bool useSsl, string cert, string sqlDialect, string database, CancellationToken cancellationToken = default) { - TTransport socket = useSsl ? - new TTlsSocketTransport(host, port, null, timeout, new X509Certificate2(File.ReadAllBytes(cert))) : - new TSocketTransport(host, port, null, timeout); + TTransport socket; + if (IPAddress.TryParse(host, out var ipAddress)) + { + socket = useSsl + ? new TTlsSocketTransport(ipAddress, port, null, timeout, new X509Certificate2(File.ReadAllBytes(cert))) + : new TSocketTransport(ipAddress, port, null, timeout); + } + else + { + socket = useSsl + ? new TTlsSocketTransport(host, port, null, timeout, new X509Certificate2(File.ReadAllBytes(cert))) + : new TSocketTransport(host, port, null, timeout); + } var transport = new TFramedTransport(socket);