我遇到了PayPal REST Api的问题,有时它工作正常!(并且在沙箱上它可以100%工作)但是在连接到现场PayPal系统时在实时系统上.我有时会得到跟随错误.
PayPal.ConnectionException: Invalid HTTP response: The request was aborted: Could not create SSL/TLS secure channel. at
PayPal.Api.HttpConnection.Execute(String payLoad, HttpWebRequest
httpRequest) at PayPal.Api.PayPalResource.ConfigureAndExecute[T]
(APIContext apiContext, HttpMethod httpMethod, String resource, String
payload, String endpoint, Boolean setAuthorizationHeader) at
PayPal.Api.OAuthTokenCredential.GenerateOAuthToken() at
PayPal.Api.OAuthTokenCredential.GetAccessToken()
Run Code Online (Sandbox Code Playgroud)
基本上只是在尝试从PayPal获取访问令牌时继续崩溃
我已将SDK更新到最新版本,代码已经愉快地工作了3个月.
The*_*ear 14
在某些情况下,由于某种原因,PayPal连接似乎没有被释放.这会产生错误,因为.Net与任何单个主机的并发Web连接数有限制,该限制为2.
在尝试连接到PayPal之前添加它,记住它需要在每次连接之前进行,例如,如果您使用SDK和快速结账.
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.DefaultConnectionLimit = 9999;
//PayPay SDK connection
var apiContext = Configuration.GetAPIContext();
Run Code Online (Sandbox Code Playgroud)
发生此错误是因为PayPal已开始放弃对SSLv3的支持.关于接受的答案,只Tls12需要设置即可使PayPal连接再次工作.
我不想在我的代码中实现这个设置.我发现将此设置放在Application_Start()我的global.asax文件的方法中是最好的解决方案.
此外,我的4.0版.NET框架不允许我使用该SecurityProtocolType.Tls12标志 - 但如果我像这样投射它可以工作:
protected void Application_Start()
{
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; // This is equivalent to SecurityProtocolType.Tls12
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5161 次 |
| 最近记录: |