Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception While Reading Response Headers #1772

Closed
toddca opened this issue Mar 3, 2022 · 6 comments
Closed

Exception While Reading Response Headers #1772

toddca opened this issue Mar 3, 2022 · 6 comments

Comments

@toddca
Copy link

toddca commented Mar 3, 2022

I recently upgrade my application from Net5 to Net6 as well as RestSharp to 107.3.0. I have run into issues (stack below) while using this library to access a few totally unrelated REST services. Looking at the Git for this project I believe I have tracked down the method for which the exception is being thrown to:

public static IReadOnlyCollection<HeaderParameter> GetHeaderParameters(this HttpHeaders httpHeaders)
which is an extension method GetHeaderParameters() however I am unclear why accessing the HttpHeaders in this manner would throw this exception. My first thought was the Http Headers being returned where malformed however this is occuring accross at leat two different and unrelated REST based services.

System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Net.Http.Headers.HttpHeaders.ReadStoreValues[T](Span`1 values, Object storeValue, HttpHeaderParser parser, Int32& currentIndex)
at System.Net.Http.Headers.HttpHeaders.GetStoreValuesAsStringOrStringArray(HeaderDescriptor descriptor, Object sourceValues, String& singleValue, String[]& multiValue)
at System.Net.Http.Headers.HttpHeaders.GetEnumeratorCore()+MoveNext()
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()
at RestSharp.RestResponse.<>c__DisplayClass0_0.<g__GetDefaultResponse|0>d.MoveNext()
--- End of stack trace from previous location ---
at RestSharp.RestResponse.<>c__DisplayClass0_0.<g__GetDefaultResponse|0>d.MoveNext()
--- End of stack trace from previous location ---
at RestSharp.RestResponse.FromHttpResponse(HttpResponseMessage httpResponse, RestRequest request, Encoding encoding, CookieCollection cookieCollection, CalculateResponseStatus calculateResponseStatus, CancellationToken cancellationToken)
at RestSharp.RestClient.ExecuteAsync(RestRequest request, CancellationToken cancellationToken)
at Bond.Clients.Rest.BaseRestClient.<>c__DisplayClass26_0`1.<b__0>d.MoveNext() in C:\agent\_work\1\s\Bond\src\Bond.Clients\Rest\BaseRestClient.cs:line 120
--- End of stack trace from previous location ---
at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Func`5 onRetryAsync, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider, Boolean continueOnCapturedContext)
at Polly.AsyncPolicy.ExecuteAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, Boolean continueOnCapturedContext)
at Bond.Clients.Rest.BaseRestClient.ExecuteAsync[T](RestRequest request, Boolean throwIfError, CancellationToken cancellationToken) in C:\agent\_work\1\s\Bond\src\Bond.Clients\Rest\BaseRestClient.cs:line 0
at Bond.Annaware.Clients.OrdersClient.GetByOrderGuidAsync(Guid guid, CancellationToken cancellationToken) in C:\agent\_work\1\s\Bond\src\Bond.Annaware\Clients\OrdersClient.cs:line 44
at Bond.Commerce.Services.Annaware.AnnawareWebServiceRepository.GetOrderByUniqueIdAsync(String uniqueId, CancellationToken cancellationToken) in C:\agent\_work\1\s\Bond\src\Bond.Commerce\Services\Annaware\AnnawareWebServiceRepository.cs:line 157
at Bond.Commerce.Services.Annaware.AnnawareOrderLookupService.InternalGetAnnawareOrderAsync(Guid id) in C:\agent\_work\1\s\Bond\src\Bond.Commerce\Services\Annaware\AnnawareOrderLookupService.cs:line 277
@toddca
Copy link
Author

toddca commented Mar 3, 2022

The issue may be related to this net6 issue: #dotnet/runtime#61798

@MihaZupan
Copy link

Any chance you are using NewRelic in the process / on the host machine?

@toddca
Copy link
Author

toddca commented Mar 3, 2022

@MihaZupan in fact yes, it is running on this particular site. I have disabled the agent for this site and monitoring to see if this happens again sans NewRelic.

@MihaZupan
Copy link

This has been resolved if you update their agent to v9.2.0+ (newrelic/newrelic-dotnet-agent#803)

@alexeyzimarev
Copy link
Member

@toddca shall I keep it open?

@toddca
Copy link
Author

toddca commented Mar 12, 2022

Please close - upgrading the NewRelic agent fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants