Skip to content

NetworkInformationException: Permission denied (.NET 8 + Docker +GCloud) #94794

Closed
@christosk92

Description

@christosk92

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Identical code (below) that works fine in .NET 7, fails with the following error in .NET 8:

Unhandled exception. System.Net.NetworkInformation.NetworkInformationException (13): Permission denied
2023-11-16 02:04:53.524 JST
   at System.Net.NetworkInformation.NetworkChange.CreateSocket()
2023-11-16 02:04:53.524 JST
   at System.Net.NetworkInformation.NetworkChange.add_NetworkAddressChanged(NetworkAddressChangedEventHandler value)
2023-11-16 02:04:53.524 JST
   at System.Net.Http.HttpConnectionPoolManager.StartMonitoringNetworkChanges()
2023-11-16 02:04:53.524 JST
   at System.Net.Http.HttpConnectionPool.HandleAltSvc(IEnumerable`1 altSvcHeaderValues, Nullable`1 responseAge)
2023-11-16 02:04:53.524 JST
   at System.Net.Http.HttpConnectionPool.ProcessAltSvc(HttpResponseMessage response)
2023-11-16 02:04:53.524 JST
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
2023-11-16 02:04:53.524 JST
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
2023-11-16 02:04:53.524 JST
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)

Trimmed and adjusted code (same result for ANY https call):

var httpClient = new HttpClient();
_ = await httpClient.GetAsync("https://www.google.com");

The peculiarity of this issue lies in the fact that the code executes fine on a local environment. But the moment the container is spun up in a google cloud run instance, it fails.

Another weird thing is that raw TCP connections work fine, we have a database connection that goes directly over TCP, rather than traditional HTTP(s).

I have spent hours debugging this issue, and sadly we have no other choice but to revert back to .NET 7 for the time being.

Expected Behavior

A Proper HTTPs connection

Steps To Reproduce

No response

Exceptions (if any)

NetworkInformationException

.NET Version

.NET 8

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions