为什么我的NuGet客户端下载包失败?

JFrog支持
2023-02-26 20:25

如果您无法从nuget远程存储库(例如nuget gallery)下载(缓存),请检查request.log以查看对nuget包的请求是否通过具有有效权限的用户进行了身份验证。

如果确实发送了带有有效凭证的请求,并且用户拥有缓存远程工件所需的所有权限,那么问题可能与代理设置有关。

当尝试从nuget库下载nuget包时,nuget库会重定向到另一个下载服务器,因此代理必须允许从重定向的URL下载。

为了确保问题不在Artifactory方面,尝试通过代理从Artifactory机器直接从nuget gallery下载所请求的包。通过这种方式,您将能够确定是否是代理问题。


例如,您可以在Artifactory机器上运行以下命令(更改代理详细信息)并查看结果:

curl -fv -x http://user:password@proxyhost:proxyport "http://www.nuget.org/api/v2/package/CKEditor/3.6.4" -L > file.pkg

*即将连接()到代理localhost端口8888 (#0)

*尝试127.0.0.1…

% Total % Received % Xferd Average Speed Time Time当前时间

Dload上传总花费左速度

0 0 0 0 0 0 0 -: -: - -: - -: - -: - -: - 0*连接到localhost(127.0.0.1)端口8888 (#0)

> GET http://www.nuget.org/api/v2/package/CKEditor/3.6.4 HTTP/1.1

> User-Agent: curl/7.29.0 . txt

>主机:www.nuget.org

>接受:*/*

>代理连接:Keep-Alive

>

< HTTP/1.1 302找到

< Cache-Control: private

< Content-Type: text/html;utf - 8字符集=

<位置:http://az320820.vo.msecnd.net/packages/ckeditor.3.6.4.nupkg

< Server: Microsoft-IIS/8.0

< X-AspNetMvc-Version: 4.0

< X-AspNet-Version: 4.0.30319

< X-Powered-By: ASP。网

< X-Frame-Options:拒绝

< X-XSS-Protection: 1;模式=块

< X-Content-Type-Options: nosniff

< Strict-Transport-Security: maxage=31536000;includeSubDomains

<日期:周四,2014年9月25日21:41:24 GMT

< Content-Length: 176

<代理连接:Keep-alive

<

*忽略响应体

{[数据未显示]

100 176 100 176 00 788 0 -: -: - -: - -: - -: -: - 792

*连接#0到主机localhost不受影响

*向此URL发出另一个请求:“http://az320820.vo.msecnd.net/packages/ckeditor.3.6.4.nupkg”

*即将连接()到代理localhost端口8888 (#1)

*尝试127.0.0.1…

*连接到本地主机(127.0.0.1)端口8888 (#1)

> GET http://az320820.vo.msecnd.net/packages/ckeditor.3.6.4.nupkg HTTP/1.1

> User-Agent: curl/7.29.0 . txt

>主机:az320820.vo.msecnd.net

>接受:*/*

>代理连接:Keep-Alive

>

< http /1.1 200 ok

< Accept-Ranges:字节

< Content-Type: application/zip

<日期:周四,2014年9月25日21:41:25 GMT

< Etag: 0x8CFE8D69FC5DD93

< Last-Modified: Wed, 06 Mar 2013 23:08:18 GMT

<服务器:ECAcc (rhv/811F)

< X-Cache: HIT

< x-ms-blob-type: BlockBlob

< x-ms-lease-status:解锁

< x-ms-request-id: ec05a099-0001-0073-110b-5c576a000000

< x-ms-version: 2009-09-19

< Content-Length: 1066902

<代理连接:Keep-alive

<

{[数据未显示]

100 1041k 100 1041k 00 1170k 0 -: -: - - -: - - -: - - -: - - - 1170k

*连接#1到主机localhost完好无损

正如您所看到的,在上面的示例中,nuget服务器将请求重定向到另一个下载服务器,客户端遵循重定向并下载文件。这也体现在NuGet文档

当代理出现问题时,您将看到与HTTP 200不同的状态。