Closed remunda closed 7 years ago
You could use WebClient.UploadStringTaskAsync() instead or even HttpClient altogether. There isn't much stack trace available with this error. It's something that is not even easily captured.
Not awaiting lets the Controller action method complete at which point, ASP.NET realizes this logging thread is still active and throws this exception.
So essentially, this error manifests in an API call that completes quick than the logging can post the string. This occurs in most of the action methods in one of my apps, so I had to temporarily disable logging.
Hi
Since the library targets framework v4.0 we cannot use HttpClient
in the main package of gelf4net
there is a package a standalone library that uses HttpClient
.
During the weeked I'll make some tests and change WebClient.UploadStringAsync
to WebClient.UploadStringTaskAsync()
And I'll update the License in order to close this issue https://github.com/jjchiw/gelf4net/issues/40
Ok I decided to remove support for framework 4.0.....
So everything is now with HttpClient
There's not awaited call which can cause random crash of Web application.
[InvalidOperationException: An asynchronous module or handler completed while an asynchronous operation was still pending.]
https://github.com/jjchiw/gelf4net/blob/master/src/Gelf4net/Appender/GelfHttpAppender.cs#L48