Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

System.Net.Http.WinHttpException: 'A connection with the server could not be established'

Open Mike-E-angelo opened this issue 8 years ago • 11 comments

I am diving into the Azure Functions pool here, and have created a v2 project from scratch with Anonymous authorization and Storage Emulator. Simply hitting F5 after this, I get intermittent errors with the following message:

System.Net.Http.WinHttpException: 'A connection with the server could not be established'

Not sure if this is a known issue, but wanted to make sure it's captured and hopefully track it down. Obviously not a good feeling/experience seeing an error being thrown every few seconds when starting a simple, new project. 😆

Mike-E-angelo avatar Mar 21 '18 07:03 Mike-E-angelo

FWIW, here's a sample of what I am seeing from the debug output:

Exception thrown: 'System.Net.Http.WinHttpException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'Microsoft.WindowsAzure.Storage.StorageException' in Microsoft.WindowsAzure.Storage.dll
Exception thrown: 'Microsoft.WindowsAzure.Storage.StorageException' in System.Private.CoreLib.dll
Exception thrown: 'Microsoft.WindowsAzure.Storage.StorageException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in Microsoft.Azure.WebJobs.Host.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
Exception thrown: 'System.AggregateException' in System.Private.CoreLib.dll
Exception thrown: 'System.AggregateException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.WinHttpException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.WinHttpException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll

Mike-E-angelo avatar Mar 21 '18 07:03 Mike-E-angelo

Just noticed another error, not sure if it's related and/or known issue.

Error writing logs to table storage: Microsoft.WindowsAzure.Storage.StorageException: An error occurred while sending the request. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: A connection with the server could not be established
[3/21/2018 9:23:10 AM]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[3/21/2018 9:23:10 AM]    at System.Threading.Tasks.RendezvousAwaitable`1.GetResult()
[3/21/2018 9:23:10 AM]    at System.Net.Http.WinHttpHandler.<StartRequest>d__105.MoveNext()
[3/21/2018 9:23:10 AM]    --- End of inner exception stack trace ---
[3/21/2018 9:23:10 AM]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[3/21/2018 9:23:10 AM]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[3/21/2018 9:23:10 AM]    at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
[3/21/2018 9:23:10 AM]    at System.Net.Http.DiagnosticsHandler.<SendAsync>d__2.MoveNext()
[3/21/2018 9:23:10 AM] --- End of stack trace from previous location where exception was thrown ---
[3/21/2018 9:23:10 AM]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[3/21/2018 9:23:10 AM]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[3/21/2018 9:23:10 AM]    at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
[3/21/2018 9:23:10 AM]    at System.Net.Http.HttpClient.<FinishSendAsyncUnbuffered>d__59.MoveNext()
[3/21/2018 9:23:10 AM] --- End of stack trace from previous location where exception was thrown ---
[3/21/2018 9:23:10 AM]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[3/21/2018 9:23:10 AM]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[3/21/2018 9:23:10 AM]    at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.<ExecuteAsyncInternal>d__4`1.MoveNext()
[3/21/2018 9:23:10 AM]    --- End of inner exception stack trace ---
[3/21/2018 9:23:10 AM]    at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.<ExecuteAsyncInternal>d__4`1.MoveNext()
[3/21/2018 9:23:10 AM] --- End of stack trace from previous location where exception was thrown ---
[3/21/2018 9:23:10 AM]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[3/21/2018 9:23:10 AM]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[3/21/2018 9:23:10 AM]    at Microsoft.WindowsAzure.Storage.Table.TableBatchOperation.<>c__DisplayClass36_0.<<ExecuteAsync>b__0>d.MoveNext()
[3/21/2018 9:23:10 AM] --- End of stack trace from previous location where exception was thrown ---
[3/21/2018 9:23:10 AM]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[3/21/2018 9:23:10 AM]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[3/21/2018 9:23:10 AM]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[3/21/2018 9:23:10 AM]    at Microsoft.Azure.WebJobs.Logging.Utility.<SafeExecuteAsync>d__7.MoveNext()
[3/21/2018 9:23:10 AM] --- End of stack trace from previous location where exception was thrown ---
[3/21/2018 9:23:10 AM]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[3/21/2018 9:23:10 AM]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[3/21/2018 9:23:10 AM]    at Microsoft.Azure.WebJobs.Logging.Utility.<WriteBatchAsync>d__9`1.MoveNext()
[3/21/2018 9:23:10 AM] --- End of stack trace from previous location where exception was thrown ---
[3/21/2018 9:23:10 AM]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[3/21/2018 9:23:10 AM]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[3/21/2018 9:23:10 AM]    at Microsoft.Azure.WebJobs.Logging.LogWriter.<FlushTimelineAggregateAsync>d__22.MoveNext()
[3/21/2018 9:23:10 AM] --- End of stack trace from previous location where exception was thrown ---
[3/21/2018 9:23:10 AM]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[3/21/2018 9:23:10 AM]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[3/21/2018 9:23:10 AM]    at Microsoft.Azure.WebJobs.Logging.LogWriter.<FlushCoreAsync>d__25.MoveNext()
[3/21/2018 9:23:10 AM] Request Information
[3/21/2018 9:23:10 AM] RequestID:
[3/21/2018 9:23:10 AM] RequestDate:
[3/21/2018 9:23:10 AM] StatusMessage:
[3/21/2018 9:23:10 AM]
[3/21/2018 9:23:10 AM] Microsoft.WindowsAzure.Storage: An error occurred while sending the request. System.Private.CoreLib: An error occurred while sending the request. System.Private.CoreLib: A connection with the server could not be established.

Mike-E-angelo avatar Mar 21 '18 09:03 Mike-E-angelo

Same problem over here. I have a function triggered by a queue. This function calls HttpClient's GetAsync several times with await. It keeps failing with that same message. It doesn't always fail. There's a 10% chance it will get that error. I have no clue why. The function retry mechanism is working so no real harm so far.

Any help would be appreciated :)

eyalellenbogen avatar May 13 '18 18:05 eyalellenbogen

I'm also having this issue with Azure Functions when connecting to Table and Document DB. Hoping someone can find a solution to this or I can soon, since the retry mechanism isn't going to work for my solution :-/

larryeby avatar Jun 18 '18 18:06 larryeby

Is this still relevant? Lots of changes have happened to v2 since this was posted (apologies for the delay)

ColbyTresness avatar Dec 04 '18 18:12 ColbyTresness

I cannot speak for others but I have not had the opportunity to try this out lately. I am OK with waiting for feedback from others and if no one else chimes in we can close it until I get the opportunity.

Mike-E-angelo avatar Dec 05 '18 08:12 Mike-E-angelo

Sorry, but I haven't touched that project in a long time. I have no idea if it's still an issue.

eyalellenbogen avatar Dec 06 '18 11:12 eyalellenbogen

Hi, I have developed the function app v2 with Service bus trigger - https://oneprofilesyncappeus.azurewebsites.net and deployed to the production three weeks back and seeing this issue being logged from 22nd Dec in the App insight. As per the error message and stack trace I see this error happening in the Azure function module well before message is received in my programming module.

Error Message: Error while copying content to a stream. The write operation failed, see inner exception. Error 12030 calling WinHttpWriteData, 'The connection with the server was terminated abnormally'.

Stack Trace System.Net.Http.HttpRequestException: at System.Net.Http.HttpContent+d__47.MoveNext (System.Net.Http, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Net.Http.WinHttpHandler+d__131.MoveNext (System.Net.Http, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Net.Http.WinHttpHandler+d__105.MoveNext (System.Net.Http, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Net.Http.DiagnosticsHandler+d__2.MoveNext (System.Net.Http, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) Inner exception System.IO.IOException handled at System.Net.Http.HttpContent+d__47.MoveNext: at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable+ConfiguredValueTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Net.Http.HttpContent+d__47.MoveNext (System.Net.Http, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) Inner exception System.Net.Http.WinHttpException handled at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw:

sprabhus avatar Dec 24 '18 04:12 sprabhus

@fabiocav Can you help me triage this?

ColbyTresness avatar Jan 18 '19 19:01 ColbyTresness

@fabiocav ping

ColbyTresness avatar Jun 11 '19 00:06 ColbyTresness

We get the similar issue intermittently when file is moved to ADLS . Any update on this?

System.Net.Http.HttpRequestException: at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Net.Http.DiagnosticsHandler+<SendAsync>d__2.MoveNext (System.Net.Http, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) Inner exception System.Net.Http.WinHttpException handled at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw: at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Threading.Tasks.RendezvousAwaitable1.GetResult (System.Net.Http, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at System.Net.Http.WinHttpHandler+d__105.MoveNext (System.Net.Http, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)

pbakhil avatar Apr 20 '20 04:04 pbakhil