-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.Data.SqlClientos-linuxLinux OS (any supported distro)Linux OS (any supported distro)os-mac-os-xmacOS aka OSXmacOS aka OSX
Milestone
Description
The newest versions of System.Data.SqlClient throws when connecting to SQL Azure when running inside a Docker linux container.
4.7.0-preview6.19303.8does not throw4.7.0-preview7.19362.9and4.7.0-preview8.19405.3throws when run in Docker
I have tried both the debian and alpine images and both seems to produce the exception. The code works fine on Windows.
I have also not seen any issues when connecting to a "real" SQL Server, but I have not investigated this thoroughly.
The reproducing code is the following:
using System.Data.SqlClient;
namespace Repro145
{
class Program
{
static void Main()
{
using (var connection = new SqlConnection(ConnectionString))
{
connection.Open();
var command = new SqlCommand("SELECT * FROM Catalog.Device", connection);
// System.Data.SqlClient 4.7.0-preview7.19362.9 and later throws when run in Docker
// System.Data.SqlClient 4.7.0-preview6.19303.8 does not throw
var reader = command.ExecuteReader();
while (reader.Read()) ;
connection.Close();
}
}
private const string ConnectionString = "Server=tcp:xxx.database.windows.net,1433;Initial Catalog=xxx;Persist Security Info=False;User ID=xxx;Password=xxx;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
}
}
.csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.2" />
<!-- Does not throw -->
<!--<PackageReference Include="System.Data.SqlClient" Version="4.7.0-preview6.19303.8" />-->
<!-- Throws -->
<PackageReference Include="System.Data.SqlClient" Version="4.7.0-preview7.19362.9" />
</ItemGroup>
</Project>
Dockerfile
FROM mcr.microsoft.com/dotnet/core/runtime:3.0.0-preview8-buster-slim AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.0.0-preview8-buster AS build
WORKDIR /src
COPY ["Repro145/Repro145.csproj", "Repro145/"]
RUN dotnet restore "Repro145/Repro145.csproj"
COPY . .
WORKDIR "/src/Repro145"
RUN dotnet build "Repro145.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Repro145.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Repro145.dll"]
Full stacktrace
System.Data.SqlClient.SqlException
HResult=0x80131904
Message=A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 35 - An internal exception was caught)
Source=Core .Net SqlClient Data Provider
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParserStateObject.ThrowExceptionAndWarning(Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
at System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()
at System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket()
at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer()
at System.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte& value)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at Repro145.Program.Main() in C:\Source\repro145\Repro145\Program.cs:line 17
Inner Exception 1:
IOException: The decryption operation failed, see inner exception.
Inner Exception 2:
SslException: Decrypt failed with OpenSSL error - SSL_ERROR_SSL.
Inner Exception 3:
OpenSslCryptographicException: error:1408F10B:SSL routines:ssl3_get_record:wrong version number
This issue is related to dotnet/SqlClient#145 for the Microsoft.Data.SqlClient equivalent.
RobSiklos
Metadata
Metadata
Assignees
Labels
area-System.Data.SqlClientos-linuxLinux OS (any supported distro)Linux OS (any supported distro)os-mac-os-xmacOS aka OSXmacOS aka OSX
