runtime icon indicating copy to clipboard operation
runtime copied to clipboard

.Net Core 2.2 Exception 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException'

Open matendie opened this issue 7 years ago • 17 comments

This exception is continuing to show up... Exception thrown: 'System.NotImplementedException' in System.Private.CoreLib.dll Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 1364.9437ms 500 text/html; charset=utf-8 Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll The thread 0x1148 has exited with code 0 (0x0). Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll The thread 0x6538 has exited with code 0 (0x0). Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll

matendie avatar Mar 27 '19 13:03 matendie

Could you share some simle repro code @matendie ? This is not actionable without more details. Also include info about your os and general environment.

wfurt avatar Mar 27 '19 17:03 wfurt

hm... I have another .NET core 2.2 API that doesn't have this issue. The problematic one is already complex enough that It will be difficult for me to figure out what triggers it. I don't think its the system, since I have another API that is not having this problem.

Let me investigate a little more before I can give you more info. Looks like its related to some other assembly I'm including, but not sure which one.

Tad

On Wed, Mar 27, 2019 at 1:46 PM Tomas Weinfurt [email protected] wrote:

Could you share some simle repro code @matendie https://github.com/matendie ? This is not actionable without more details. Also include info about your os and general environment.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dotnet/corefx/issues/36401#issuecomment-477275887, or mute the thread https://github.com/notifications/unsubscribe-auth/AHUHs2ea2yJnhZW_Wsyz-MtzrDZnUSiHks5va66CgaJpZM4cNvPn .

matendie avatar Mar 27 '19 18:03 matendie

I've seen this exception on Linux this past week using .NET Dns.GetHostAddressesAsync I will try to post repro code soon. It was trying to resolve a name that couldn't be resolved.

This exception is unusual. We should never be exposing System.Net.Internals.SocketExceptionFactory.ExtendedSocketException to an API caller of Socket or DNS APIs. It should have been transformed into a SocketException, for example.

davidsh avatar Mar 27 '19 18:03 davidsh

Im running Windows 10 as a parallel on Mac Pro. Don't ask, not my decision, LOL. Im not sure when this exception started showing up, i just noticed it today when my call to external API failed and I used tracing to look at the stack and the request. I have some remaining nuget libs that I need to get cleared up. Some didn't do what I needed. I can give you a list of things my projects include. If that helps at all for now?

Tad

On Wed, Mar 27, 2019, 2:57 PM David Shulman [email protected] wrote:

I've seen this exception on Linux this past week using .NET Dns.GetHostAddressesAsync I will try to post repro code soon. It was trying to resolve a name that couldn't be resolved.

This exception is unusual. We should never be exposing System.Net.Internals.SocketExceptionFactory.ExtendedSocketException to an API caller of Socket or DNS APIs. It should have been transformed into a SocketException, for example.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dotnet/corefx/issues/36401#issuecomment-477303755, or mute the thread https://github.com/notifications/unsubscribe-auth/AHUHs-Jxaw_HPfLtFziE5wqOfURz4fhSks5va78mgaJpZM4cNvPn .

matendie avatar Mar 27 '19 19:03 matendie

Here are the included libraries in the project... Like I said, I'm not sure if its related to any of these, but if you see anything that may be a suspect, that you want me to try removing to test, let me know.

[image: image.png]

[image: image.png]

On Wed, Mar 27, 2019 at 2:57 PM David Shulman [email protected] wrote:

I've seen this exception on Linux this past week using .NET Dns.GetHostAddressesAsync I will try to post repro code soon. It was trying to resolve a name that couldn't be resolved.

This exception is unusual. We should never be exposing System.Net.Internals.SocketExceptionFactory.ExtendedSocketException to an API caller of Socket or DNS APIs. It should have been transformed into a SocketException, for example.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dotnet/corefx/issues/36401#issuecomment-477303755, or mute the thread https://github.com/notifications/unsubscribe-auth/AHUHs-Jxaw_HPfLtFziE5wqOfURz4fhSks5va78mgaJpZM4cNvPn .

matendie avatar Mar 27 '19 19:03 matendie

@matendie Your last message didn't include any actual screenshots. It just says "image.png". Using email-reply to GitHub issue will strip out attachments.

davidsh avatar Mar 27 '19 20:03 davidsh

here is more info on what's in the project:

Library responsible to AAD Bearer Token Authentication:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
    <PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="4.5.1" />
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.4.0" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System.IdentityModel.Tokens.Jwt">
      <HintPath>..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\system.identitymodel.tokens.jwt\5.2.0\lib\netstandard1.4\System.IdentityModel.Tokens.Jwt.dll</HintPath>
    </Reference>
  </ItemGroup>
</Project>

API that gets called from outside and calls other external APIs:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <UserSecretsId>guid</UserSecretsId>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="2.2.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
    <PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
    <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.1" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Custom.ADAuthentication.Provider\Custom.ADAuthentication.Provider.csproj" />
    <ProjectReference Include="..\Custom.projectDataLayer.Service\Custom.projectDataLayer.Service.csproj" />    
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Swagger\" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="HibernatingRhinos.Profiler.Appender">
      <HintPath>..\..\..\Users\username\Downloads\EntityFramework.Profiler-v5.0-Build-5032\Appender\net46\HibernatingRhinos.Profiler.Appender.dll</HintPath>
    </Reference>
  </ItemGroup>
</Project>

Data Layer EF specific :

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.2" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Command\" />
  </ItemGroup>
</Project>

I did have a custom library but I removed it since I didn't need it: https://github.com/hanssens/localstorage

matendie avatar Mar 28 '19 12:03 matendie

@davidsh do you have suggestions for next steps?

karelz avatar Apr 25 '19 23:04 karelz

@davidsh do you have suggestions for next steps?

Next step is for us to reproduce the problem and see where this weird exception is coming from.

davidsh avatar Apr 26 '19 00:04 davidsh

I'm looking in to this again... I switched over from VS2017 Pro to VS 2019 Pro and the exception is no longer showing in output window. If I open it back in VS2017 Pro exception shows back up again

Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll

I'm not sure what the debugger difference is between the two VS versions, could new one be hiding it, or is the old one causing it?

No Idea.

matendie avatar Apr 26 '19 12:04 matendie

There should be no difference in the same .NET Core 2.2 version behavior in one VS or another, or outside. Can you please run it outside of VS? I would also recommend trying older VS 2017 in a brand new VM with fresh installation to avoid some corrupted install /config problems.

karelz avatar Apr 27 '19 03:04 karelz

I'm not sure how to run it outside of VS and have visibility to exceptions thrown... I published this API to Azure and I don't see any exceptions thrown in Application Insights. Maybe this is a VS 2017 issue?

matendie avatar Apr 29 '19 12:04 matendie

You can try to isolate it and move it outside of ASP.NET Core first. Or you can try to create repro on brand new VM (fresh install).

Rather than VS 2017 issue, it is more likely to be some weird environment setting / debugging setting in your VS. I recommend to not chase it down, unless you have something actionable - you may opt in to debug the exception and find out what triggered it. Closing for now, feel free to reopen if there is anything actionable for us. Thanks!

karelz avatar Apr 29 '19 16:04 karelz

Ok will do, thank you!

On Mon, Apr 29, 2019, 12:08 PM Karel Zikmund [email protected] wrote:

You can try to isolate it and move it outside of ASP.NET Core first. Or you can try to create repro on brand new VM (fresh install).

Rather than VS 2017 issue, it is more likely to be some weird environment setting / debugging setting in your VS. I recommend to not chase it down, unless you have something actionable - you may opt in to debug the exception and find out what triggered it. Closing for now, feel free to reopen if there is anything actionable for us. Thansk!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dotnet/corefx/issues/36401#issuecomment-487641127, or mute the thread https://github.com/notifications/unsubscribe-auth/AB2QPM7COZONRJIVBCAVFGDPS4MPFANCNFSM4HBW6PTQ .

matendie avatar May 03 '19 10:05 matendie

I have the same issue, it does not provide much information for troubleshooting.

lhsomoza avatar May 08 '19 16:05 lhsomoza

can you isolate simple corefx repro @lhsomoza notes here are not actionable so far.

wfurt avatar May 08 '19 17:05 wfurt

Ran into this problem as well. I see

Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Private.CoreLib.dll

in the VS 2019 debug output, and my console application exits with status 0. This exception goes around my try-catch blocks, nothing reported in the event viewer, seems downright impossible to debug. This is on Core 3.1.

UPDATE: my issue was back-to-back NetworkStream.WriteAsync and NetworkStream.ReadAsync - I wanted to say something to the server and get response. Adding 100ms delay prevents the problem. I am not happy with this solution, so I will keep looking into the right way to do this, but at least I know what's causing the silent crash.

        await _stream!.WriteMessageAsync(request, cancellationToken, _client!.SendBufferSize)
            .ConfigureAwait(false);

        Thread.Sleep(100);

        return await GetResponseAsync(cancellationToken)
            .ConfigureAwait(false);

Corys9 avatar Mar 03 '20 01:03 Corys9