Skip to content

Commit 9fd7a9c

Browse files
authored
Upgrade ApacheThrift to 0.22.0 and fix socket transport creation (#52)
* Upgrade ApacheThrift to 0.22.0 * Use aspnet 9.0 for samples Docker image
1 parent d1298e2 commit 9fd7a9c

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

samples/Apache.IoTDB.Samples/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
1919

20-
FROM mcr.microsoft.com/dotnet/runtime:9.0 AS base
20+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
2121
WORKDIR /app
2222

2323
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build

src/Apache.IoTDB/Apache.IoTDB.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="ApacheThrift" Version="0.14.1" />
20+
<PackageReference Include="ApacheThrift" Version="0.22.0" />
2121
</ItemGroup>
22-
<ItemGroup
23-
Condition="'$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'netstandard2.0'">
22+
<ItemGroup Condition="'$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'netstandard2.0'">
2423
<PackageReference Include="IndexRange" Version="1.0.2" />
2524
</ItemGroup>
2625
<ItemGroup>
27-
<None Include="../../README.md" Pack="true" PackagePath="\"/>
26+
<None Include="../../README.md" Pack="true" PackagePath="\" />
2827
</ItemGroup>
2928

3029
</Project>

src/Apache.IoTDB/SessionPool.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using System.Collections.Generic;
2222
using System.IO;
2323
using System.Linq;
24+
using System.Net;
2425
using System.Security.Cryptography.X509Certificates;
2526
using System.Threading;
2627
using System.Threading.Tasks;
@@ -449,10 +450,18 @@ public async Task<string> GetTimeZone()
449450

450451
private async Task<Client> CreateAndOpen(string host, int port, bool enableRpcCompression, int timeout, bool useSsl, string cert, string sqlDialect, string database, CancellationToken cancellationToken = default)
451452
{
453+
TTransport socket;
452454

453-
TTransport socket = useSsl ?
454-
new TTlsSocketTransport(host, port, null, timeout, new X509Certificate2(File.ReadAllBytes(cert))) :
455-
new TSocketTransport(host, port, null, timeout);
455+
if (useSsl)
456+
{
457+
socket = IPAddress.TryParse(host, out var ipAddress)
458+
? new TTlsSocketTransport(ipAddress, port, null, cert)
459+
: new TTlsSocketTransport(host, port, null, timeout, new X509Certificate2(cert));
460+
}
461+
else
462+
{
463+
socket = new TSocketTransport(host, port, false, null, timeout);
464+
}
456465

457466
var transport = new TFramedTransport(socket);
458467

0 commit comments

Comments
 (0)