Http.fs icon indicating copy to clipboard operation
Http.fs copied to clipboard

Resource temporarily unavailable

Open haf opened this issue 7 years ago • 3 comments

System.AggregateException: One or more errors occurred. (Resource temporarily unavailable) ---> System.Net.Http.HttpRequestException: Resource temporarily unavailable ---> System.Net.Sockets.SocketException: Resource temporarily unavailable
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
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.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at HttpFs.Client.getResponseOrFail@974[a,b](FSharpChoice`2 _arg1)
at Hopac.Core.ContMap`2.DoCont(Worker& wr, X x)
at Hopac.Core.Worker.RunOnThisThread(Scheduler sr, Work work) 
  • https://stackoverflow.com/questions/14370489/what-can-cause-a-resource-temporarily-unavailable-on-sock-send-command
  • https://stackoverflow.com/questions/11178220/is-httpclient-safe-to-use-concurrently
  • https://stackoverflow.com/a/7635520/63621
  • https://github.com/dotnet/corefx/issues/30623#issuecomment-399757684
  • http://byterot.blogspot.com/2016/07/singleton-httpclient-dns.html

Consider setting ConnectionLeaseTimeout in order to re-resolve DNS in order to combat the possible error that the kernel is already pending many other HTTP Client connections to the same IP.

Hypothesis:

  • Multiple ongoing connection attempts to a server that is not accepting connections
  • The server is accepting connections but immediately RST-ing them, causing the kernel .net core is running on to return EAGAIN back from send/connect
  • There's an implicit timeout in the .net core framework that triggers EAGAIN to be returned

Current idea of how to work around

  • Resend the request.

haf avatar Oct 17 '18 13:10 haf

We are getting this error as well.

CodeSwimBikeRunner avatar Oct 29 '18 15:10 CodeSwimBikeRunner

Http.fs should track this error and resend the request. PRs accepted.

haf avatar Oct 29 '18 17:10 haf

@ChristopherLClark Did you find out the cause for this? I have configured retries, but the error doesn't just disappear on its own without restarting the process.

haf avatar Nov 19 '18 13:11 haf