DotNet core 2.0 on MacOS gets libcurl and ssl error triggered by httpclient when using couchbase dotnet sdk

六月ゝ 毕业季﹏ 提交于 2019-12-05 22:22:54

Steps to Use Socket HTTP Handler

Here's what I needed to do to get this to work:

  • Install .NET Core SDK 2.1.xxx-preview
  • Update Project AspNetCore.All Reference
  • Add Package Source to NuGet.Config
  • Set Environment Variable

Install .NET Core SDK [2.1.xxx-preview]

Download and install macOs installer

Update Project AspNetCore.All Reference

Update package reference to:

<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0-preview1-final" />

Add Package Source to NuGet.Config

Update ~/.nuget/NuGet/NuGet.Config and add another package source:

<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />

I needed to do this because I was getting a NuGet error: error NU1102: Unable to find package Microsoft.AspNetCore.All with version (>= 2.1.0).

Set Environment Variable

In my Startup.cs I set an environment variable:

Environment.SetEnvironmentVariable("DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER", "true");

What We're Doing

With 2.1 dotnet will incorporate its own Socket Handler which bypasses OS specific ones and so we can avoid the macOS issues. In preview-1 we still have to manually opt-in: https://github.com/dotnet/corefx/blob/master/src/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs

But soon in preview-2 it'll be on by default: https://github.com/dotnet/corefx/pull/27821

Previous post

I've been investigating the same issue this morning and I currently don't think there's a clear solution. Dotnet Core 2.x does not resolve the issue for the Couchbase SDK, though I think using HttpClient outside of Couchbase is fine (haven't tested this).

As of Couchbase SDK Version 2.5.8 (17 March 2018) this is still a known issue: https://developer.couchbase.com/server/other-products/release-notes-archives/dotnet-sdk

Actual issue link: https://issues.couchbase.com/browse/NCBC-1296

In the forums, see:

I'll post back if I find a working solution.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!