Search code examples
c#-2.0ebay-api

Get "the underlying connection was closed an unexpected error occurred on a send" error when calling CompleteSale method


I'm having a problem calling the API's method CompleteSale via eBay_Service .NET SDK (v967) since 2 weeks (02/10).
When the ERP tries to sends some updated information about one order, it receives this Exception:

the underlying connection was closed an unexpected error occurred on a send

so I haven't got a response from the API.
There are more than one strange things:

  • there are some batch in background, using the same .dll, and they work fine;
  • after rebooting the server the first call to "CompleteSale" works fine;
  • after registering again the .dll via the "regsrv" command, it worked fine for one day;
  • all operators that uses the ERP are connected to the server via remote desktop and all of they notice the problem. Instead, if i connect from my company's office, all works fine;
  • I've tried to increase the timeout to 360 sec (from 60 sec) and nothing changed.

The ERP is developed in progress (OpenGL) , so I can't fix with setting "KeepAlive" to "false", setting the certificate explicitly (Tsl1.1 | Tsl1.2) or making other interventions on .net side. I was wrong, it can be done from the source code of the SDK.


Solution

  • i've checked the Security Protocols on the api's servers discovering that the "SSL3" is not longer supported whereas the default value for the ServicePointManager.SecurityProtocol in .NET 2.0 is SSL3.
    I've solved the problem by adding this hotfix at the "eBayXmlAPIInterfaceService" class in the SDK's source code:

    //768  = Tsl1.1,  3070 = Tsl1.2
    ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072 |
    (SecurityProtocolType)768;
    
    HttpWebRequest http = (HttpWebRequest) WebRequest.Create(this.Url);
    http.Method = "POST";
    http.ContentType = "text/xml";
    http.ContentLength = data.Length;
    http.KeepAlive = false;
    

    Probably Microsoft as released an hotfix to correct this problem but the server wesn't updated since 2015.
    Moreover i've replicated the .net code in the ABL application in a program that we use to do get/post requestes:

    DEF VAR w-tsl10 AS System.Net.SecurityProtocolType
    w-tsl10 = CAST(System.Enum:ToObject(PROGRESS.Util.TypeHelper:GetType("System.Net.SecurityProtocolType":U), 192), System.Net.SecurityProtocolType).
    ystem.Net.ServicePointManager:SecurityProtocol = w-tsl10.