erik_l

Trouble connecting/downloading packages

0 votes
I've been having a bit of trouble connecting to the Canadian sandbox environment. The specific error message I'm getting is: "Could not get package. Exception: Object reference not set to an instance of an object." Here's the code (irrelevant bits stripped out):
Dim _eslClient As New EslClient("Our API Key goes here", "https://sandbox.e-signlive.ca/api")

Dim docPackage As DocumentPackage
Dim pkgId As New PackageId("Package ID Goes Here")

docPackage = _eslClient.GetPackage(pkgId)
And that's when it throws a System.Net.Sockets.SocketException and we get the error code. For the record, I've also tried
_eslClient.SystemService.GetApplicationVersion()
without any success. That one also threw a socket exception and gave a similar error message. This is .NET Framework 4.8 (we recently upgraded). The package IDs are coming straight from the callback and we've verified the API key is correct, so I'm at a little bit of a loss. The version of Silanis.ESL.dll is 11.0.1.0 and the Runetime Version is v2.0.50727. Any thoughts?

Approved Answer

Reply to: Trouble connecting/downloading packages

1 votes
Hi erik, This error sounds like a TLS issue, have you tried to specify TLS version using below code:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 
Just put this code before you built the HttpClient object. Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Trouble connecting/downloading packages

0 votes
Oh, if it helps, this is what I'm getting in the Visual Studio output window:
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.ObjectDisposedException' in System.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.IO.IOException' in System.dll
Exception thrown: 'System.ObjectDisposedException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.NullReferenceException' in Silanis.ESL.dll
Exception thrown: 'Silanis.ESL.SDK.EslException' in Silanis.ESL.dll
And if it matters we're on Newtonsoft.Json v12.0.2

Reply to: Trouble connecting/downloading packages

1 votes
Hi there, Just a few questions first, are you connecting through a proxy? Can you connect to OSS through RESTful API? And furthermore, can you access other HTTPS resources on your server? For Test with OSS connection:
HTTP Request
POST /api/sysinfo

HTTP Headers
Accept: application/json
Content-Type: application/json
Authorization: Basic api_key
For Test with other HTTPS resources, you can try make a GET to retrieve my github repo:
HTTP Request
GET https://api.github.com/users/liangduo1993/repos

HTTP Headers
Accept, "application/json"
User-Agent, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Trouble connecting/downloading packages

0 votes
So I've verified it's working when I access the RESTful API directly (it gives 405 Method Not Allowed when I tried /api/sysinfo on the Canadian sandbox, but /api/callback gave the expected result) and for grins I tried the GitHub repo and that worked too, so I suspect you might be right and there's an issue in the corporate network firewall. I'll ask around and see if that resolves it.

Reply to: Trouble connecting/downloading packages

0 votes
I've been told it isn't the firewall, so I tried out something a little bit different. Since accessing the API directly worked in Postman, I figured I'd try it programmatically.
    Public Function TestESignConnection() As String Implements IESLDownloaderSVC.TestESignConnection
        Dim response As HttpResponseMessage
        Try
            _httpClient.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue("Authorization", "Basic ")
            _httpClient.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue("application/json"))

            response = _httpClient.GetAsync("https://sandbox.e-signlive.ca/api/callback").Result
            Return JsonConvert.SerializeObject(response)
        Catch ex As Exception
            Return ex.ToString
        End Try
    End Function
This gave the same result as the SDK:
"System.AggregateException: One or more errors occurred. ---> System.Net.Http.Http" +
    "RequestException: An error occurred while sending the request. ---> System.Net.W" +
    "ebException: The underlying connection was closed: An unexpected error occurred " +
    "on a send. ---> System.IO.IOException: Unable to read data from the transport co" +
    "nnection: An existing connection was forcibly closed by the remote host. ---> Sy" +
    "stem.Net.Sockets.SocketException: An existing connection was forcibly closed by " +
    "the remote host\r\n etc. etc.
So I'm honestly at a little bit of a loss here. It sort of seems like the problem is the app itself, although I hasten to add it's working fine in production. I'll keep checking with our network people, but for the record, could you maybe let me know what problems with a proxy I should be asking about?

Reply to: Trouble connecting/downloading packages

0 votes
Hi erik, Can I know whether your calls went through a proxy server? For applications integrated with .Net SDK, normally you don't need to specify proxy information because .Net by default will use the system default proxy. But you can always explicitly assign the proxy information as mentioned in this guide:
ProxyConfiguration httpProxyConfiguration = ProxyConfigurationBuilder.newProxyConfiguration()
                .WithHttpHost("serverAddress") //e.g. localhost
                .WithHttpPort(portNumber) //e.g. 8001
                .Build();
Boolean allowAllSSLCertificates = false;		
EslClient client = new EslClient(API_KEY, API_URL, allowAllSSLCertificates, httpProxyConfiguration);
The guide also covers the solution for RESTful calls using HttpClient. Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: Trouble connecting/downloading packages

0 votes
I've just been told, it's not being routed through a proxy server. More mysteriously the RESTful API calls aren't giving us socket exceptions when we run them in a different project, but in the normal place it's giving us that "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host." If this isn't something you're familiar with/have had customers run into before, then I guess I'll just have to keep messing around with it.

Reply to: Trouble connecting/downloading packages

0 votes
That totally worked. For use with the SDK I assume it should just go before we build the client object, correct? Like so:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
_eslClient = New EslClient(ESLAPIKey, ESLServiceURL)

Reply to: Trouble connecting/downloading packages

0 votes
Great to hear that! Yes, this code also works for the SDK. Tell us if it doesn't work as expected! Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off