core icon indicating copy to clipboard operation
core copied to clipboard

Cannot assign requested address exception

Open gstrit opened this issue 8 years ago • 2 comments

Issue Title

"Cannot assign requested address" during communication between two services.

General

I have a set of services (core 2.1.5) which are launched with Docker Swarm. For two of them, I have communication issue after some time after startup. I don't have issues the others services. So basically, I have : Service A -> Service B At startup, everything is fine. After some hours, I receive this exception. If I restart the Service container, it works during few hours...

Exception

{
  "Depth": 0,
  "ClassName": "",
  "Message": "Cannot assign requested address",
  "Source": "System.Net.Http",
  "StackTraceString": "   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at ServiceClients.TransportProcessingServiceClient.TransportProcessingServiceClient.PostFileAsync(FileContentViewModel fileContentViewModel, Guid transportConfigurationId, Guid retailerId, Guid contextId, CancellationToken cancellationToken, ILogger logger)
at TriggerManagementService.Infrastructure.Executors.ExportTradeItemImageActionExecutor.DoExecute(ExportTradeItemImageAction action) in /src/TriggerManagementService/Infrastructure/Executors/ExportTradeItemImageActionExecutor.cs:line 92
at TriggerManagementService.Infrastructure.Executors.ActionExecutor`2.Execute(T action, Dictionary`2 parameters) in /src/TriggerManagementService/Infrastructure/Executors/ActionExecutor.cs:line 49",
  "RemoteStackTraceString": "",
  "RemoteStackIndex": -1,
  "HResult": -2147467259,
  "HelpURL": null
},
{
  "Depth": 1,
  "ClassName": "",
  "Message": "Cannot assign requested address",
  "Source": "System.Private.CoreLib",
  "StackTraceString": "   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)",
  "RemoteStackTraceString": "",
  "RemoteStackIndex": -1,
  "HResult": -2147467259,
  "HelpURL": null
}

gstrit avatar Oct 19 '18 04:10 gstrit

Which OS do you run on? It seems like there are no available ports on the system. Can you check the OS stats at the point of failure? Can you check your container configuration? Once it happens (after few hours) - does it happen once / all the time / most of the time?

karelz avatar Oct 22 '18 17:10 karelz

Sorry my mistake I found the issue. The service sent a stream as a response and I did not close it.

gstrit avatar Oct 23 '18 06:10 gstrit