C# Auth0.AuthenticationApi Resource temporarily unavailable (https:443)

Hi,
i am using the Auth0.AuthenticationApi SDK to get a token for the ManagementApi.
This is my code for getting an token:

 var authClient = new AuthenticationApiClient(_auth0Settings.Domain);
 var ccRequest = new ClientCredentialsTokenRequest
 {
     Audience = _auth0Settings.Audience,
     ClientSecret = _auth0Settings.ClientSecret,
     ClientId = _auth0Settings.ClientId
 };
 var token = await authClient.GetTokenAsync(ccRequest);
 return token.AccessToken;

It was working a few times, but now i am only getting this error:

System.Net.Http.HttpRequestException: Resource temporarily unavailable (https:443)
 ---> System.Net.Sockets.SocketException (11): Resource temporarily unavailable
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|281_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)

Does anyone have any solution for me?

Hello,

It seems like you’re encountering a network-related issue while trying to make a request to the Auth0 API using the Auth0.AuthenticationApi SDK. The error message indicates a problem with connecting to the remote server. Here are some steps you can try to troubleshoot and resolve this issue:

Network Connectivity: Make sure your internet connection is stable and that you can access other websites or APIs without any issues. Sometimes, network interruptions can cause this kind of error.

Retry: Temporary network issues can cause intermittent errors. You could implement a retry mechanism to see if the issue resolves itself after a short period. You can wrap your token acquisition code in a retry loop with some delay between retries.
int maxRetries = 3;
int delayBetweenRetriesMs = 1000; // 1 second

for (int retry = 0; retry < maxRetries; retry++)
{
try
{
var token = await authClient.GetTokenAsync(ccRequest);
return token.AccessToken;
}
catch (HttpRequestException ex)
{
// Log or handle the exception
await Task.Delay(delayBetweenRetriesMs);
}
}

// If you’ve exhausted retries, handle the failure gracefully
Firewall or Proxy Issues: If you’re behind a corporate firewall or using a proxy server, ensure that your application’s network settings are correctly configured to work with these. It’s possible that network policies could be blocking your request.

API Status: Check if there are any ongoing issues or maintenance activities on the Auth0 side. Sometimes, the error might be related to the service itself, and in such cases, you might need to wait for the service to be fully operational again.

SDK and Dependencies: Ensure that you’re using the latest version of the Auth0.AuthenticationApi SDK and that you’ve correctly set up all required dependencies. Sometimes, updating the SDK can resolve compatibility issues.

DNS Resolution: The error might also be related to DNS resolution. Ensure that your DNS settings are configured correctly and that you can resolve the Auth0 domain properly.

Timeouts: If the Auth0 API is taking longer to respond than expected, you could consider increasing the timeout for your HTTP requests. However, this might not be a permanent solution and could mask underlying issues.

Logs and Debugging: Enable more detailed logging or debugging in your application to get more information about the error. This might help you pinpoint the exact cause of the issue.

Hi,
thank you for the answer!
This one really helped me a lot.
I have found my issue afterwards - a mistake in the Url…
Best Regards

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.