Skip to main content

SSL error when authenticating to Geotab SDK in .NET Core 8 background service

DFenn-1143
Original Poster

These lines are executing within the ExecuteAsync() method of the BackgroundService (Microsoft.Extensions.Hosting.BackgroundService)

 

         Console.WriteLine("Connecting to Geotab..."); // See this in the output

 

        API api = new API("xxxx@xxxx.com", "********", null, "QA_Sunbelt_Rentals", "mypreview.com");

        Task t = api.AuthenticateAsync();

        t.Wait();

        Console.WriteLine(api.SessionId); // Do NOT see this in the output

 

ex.InnerException.Message "The SSL connection could not be established, see inner exception."

 

ex.InnerException.InnerException.Message "Url: 'https://mypreview.com/apiv1'; StatusCode: 'Unused'\r\n'The SSL connection could not be established, see inner exception.''"

 

 

 

/eeidfn

Join the conversation

You need to be logged in to reply to this post and participate in the Geotab Community discussions.

6 Replies

Can you double-check the server path? I believe the preview database server path is something like preview.geotab.com (at least it is for our preview databases). If you aren't using a preview database, it would be my.geotab.com.

DFenn-1143
Original Poster

Hi Darren,

It also happens when we point to Prod (https://my45.geotab.com/apiv1)

 

Can you please help?

 

 

When did this start happening? Is this a new project, or a new error in an existing project? Also, what happens if you use the standard non-federated server (my.geotab.com instead of myXX.geotab.com)?

DFenn-1143
Original Poster

Its a new .NET 8 Core Windows Service; I feel that this is related to .NET 8 Core and the Background Service.

 

my.geotab.com is also failing.

Our primary Geotab integration is built in .NET 8 and makes extensive use of BackgroundServices to do various types of MyGeotab API work. While this fact doesn't preclude your issue from being related to the framework or BackgroundService implementation, I think there are several other more likely possibilities that I would eliminate first:

 

  1. Incorrect credentials / connection information
  2. Running environment blocking connections (e.g. a firewall)
  3. Incorrect service implementation

 

I just tried running this as a test in a sample .NET 8 console app with a simple BackgroundService implementation that mirrors your provided code:

public class TestBackgroundService : BackgroundService { protected override Task ExecuteAsync(CancellationToken stoppingToken) { var api = new API( "username", "password", null, "myDatabase", "my.geotab.com");   var t = api.AuthenticateAsync(); t.Wait(); Console.WriteLine(api.SessionId); return Task.CompletedTask; } }

And my Program.cs that registers and runs it:

using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting;   var builder = Host.CreateApplicationBuilder(args);   builder.Services.AddHostedService<TestBackgroundService>();   var host = builder.Build();   await host.RunAsync();

It authenticated successfully and printed the SessionId without issue.

 

If you can log into the MyGeotab web interface using all of the credentials provided in your example, and verify that the network you're running from is not restricting web traffic to those URL's, then the next thing I would investigate is your specific service implementation.

 

If you're still unable to get it working, feel free to share your entire code and we can try to troubleshoot further.

DFenn-1143
Original Poster

It was a .NET8 Core project setup issue. Problem has been solved.

Still have questions?