Index must be within the bounds of the List - Bug #202

Closed
opened 2025-12-29 14:25:01 +01:00 by adam · 12 comments
Owner

Originally created by @gregoks on GitHub (Aug 21, 2019).

Originally assigned to: @StefH on GitHub.

hi,

I'm getting the following error when using the MyGet version - 1.0.27-11567

I'm using it with the following properties:

MaxRequestLogCount = 100
RequestLogExpirationDuration = 6

HttpStatusCode set to 500 System.ArgumentOutOfRangeException: Index must be within the bounds of the List. Parameter name: index at System.Collections.Generic.List1.Insert(Int32 index, T item) at System.Collections.ObjectModel.ObservableCollection1.InsertItem(Int32 index, T item) at WireMock.Util.ConcurrentObservableCollection`1.InsertItem(Int32 index, T item) at WireMock.Owin.WireMockMiddleware.LogRequest(LogEntry entry, Boolean addRequest) at WireMock.Owin.WireMockMiddleware.InvokeInternal(HttpContext ctx) at WireMock.Owin.GlobalExceptionMiddleware.InvokeInternal(HttpContext ctx)

Can you please check?

Thanks :)

Greg

Originally created by @gregoks on GitHub (Aug 21, 2019). Originally assigned to: @StefH on GitHub. hi, I'm getting the following error when using the MyGet version - 1.0.27-11567 I'm using it with the following properties: MaxRequestLogCount = 100 RequestLogExpirationDuration = 6 > HttpStatusCode set to 500 System.ArgumentOutOfRangeException: Index must be within the bounds of the List. Parameter name: index at System.Collections.Generic.List`1.Insert(Int32 index, T item) at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item) at WireMock.Util.ConcurrentObservableCollection`1.InsertItem(Int32 index, T item) at WireMock.Owin.WireMockMiddleware.LogRequest(LogEntry entry, Boolean addRequest) at WireMock.Owin.WireMockMiddleware.InvokeInternal(HttpContext ctx) at WireMock.Owin.GlobalExceptionMiddleware.InvokeInternal(HttpContext ctx) Can you please check? Thanks :) Greg
adam added the bug label 2025-12-29 14:25:01 +01:00
adam closed this issue 2025-12-29 14:25:02 +01:00
Author
Owner

@StefH commented on GitHub (Aug 21, 2019):

Please try 1.0.28-ci-11744

@StefH commented on GitHub (Aug 21, 2019): Please try `1.0.28-ci-11744`
Author
Owner

@gregoks commented on GitHub (Aug 22, 2019):

I have tried using version 1.0.28 and its still happening, 1.0.28 was deployed later than 1.0.28-ci-11744?

@gregoks commented on GitHub (Aug 22, 2019): I have tried using version 1.0.28 and its still happening, 1.0.28 was deployed later than 1.0.28-ci-11744?
Author
Owner

@StefH commented on GitHub (Aug 22, 2019):

A possible fix for your problem is only present in preview version : 1.0.28-ci-11744

@StefH commented on GitHub (Aug 22, 2019): A possible fix for your problem is only present in preview version : 1.0.28-ci-11744
Author
Owner

@gregoks commented on GitHub (Sep 4, 2019):

hi @StefH , this issue still happens in version 1.0.31-ci-11865. can you please check?

@gregoks commented on GitHub (Sep 4, 2019): hi @StefH , this issue still happens in version 1.0.31-ci-11865. can you please check?
Author
Owner

@gregoks commented on GitHub (Nov 17, 2019):

hi @StefH ,

I'm using version 1.0.37 and still getting the following error:

HttpStatusCode set to 500 System.ArgumentOutOfRangeException: Index must be within the bounds of the List. Parameter name: index at System.Collections.Generic.List1.Insert(Int32 index, T item) at System.Collections.ObjectModel.ObservableCollection1.InsertItem(Int32 index, T item) at WireMock.Util.ConcurrentObservableCollection`1.InsertItem(Int32 index, T item) at WireMock.Owin.WireMockMiddleware.LogRequest(LogEntry entry, Boolean addRequest) at WireMock.Owin.WireMockMiddleware.InvokeInternal(HttpContext ctx) at WireMock.Owin.GlobalExceptionMiddleware.InvokeInternal(HttpContext ctx)

this is how I start the wiremock:

var fluentMockServer = StandAloneApp.Start(new FluentMockServerSettings
{
Port = port,
StartAdminInterface = true,
StartTimeout = 5000,
MaxRequestLogCount = 100,
RequestLogExpirationDuration = 6,
Logger = new WireMockLogger(port)
});

WireMockLogger is my class and I assign to an open port.

@gregoks commented on GitHub (Nov 17, 2019): hi @StefH , I'm using version 1.0.37 and still getting the following error: HttpStatusCode set to 500 System.ArgumentOutOfRangeException: Index must be within the bounds of the List. Parameter name: index at System.Collections.Generic.List`1.Insert(Int32 index, T item) at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item) at WireMock.Util.ConcurrentObservableCollection`1.InsertItem(Int32 index, T item) at WireMock.Owin.WireMockMiddleware.LogRequest(LogEntry entry, Boolean addRequest) at WireMock.Owin.WireMockMiddleware.InvokeInternal(HttpContext ctx) at WireMock.Owin.GlobalExceptionMiddleware.InvokeInternal(HttpContext ctx) this is how I start the wiremock: var fluentMockServer = StandAloneApp.Start(new FluentMockServerSettings { Port = port, StartAdminInterface = true, StartTimeout = 5000, MaxRequestLogCount = 100, RequestLogExpirationDuration = 6, Logger = new WireMockLogger(port) }); WireMockLogger is my class and I assign to an open port.
Author
Owner

@StefH commented on GitHub (Nov 17, 2019):

It maybe has to do with a lot of (fast) requests. Or maybe the logic for MaxRequestLogCount and RequestLogExpirationDuration is wrongly implemented. I need to make a sample where your settings are used and where I use HttpClient to send 100+ requests.

@StefH commented on GitHub (Nov 17, 2019): It maybe has to do with a lot of (fast) requests. Or maybe the logic for MaxRequestLogCount and RequestLogExpirationDuration is wrongly implemented. I need to make a sample where your settings are used and where I use HttpClient to send 100+ requests.
Author
Owner

@StefH commented on GitHub (Nov 19, 2019):

I've created a example console app:
https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.Console.RequestLogTest

Can you take a look if this is the code you use? And make a PullRequest if you have different code.

@StefH commented on GitHub (Nov 19, 2019): I've created a example console app: https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.Console.RequestLogTest Can you take a look if this is the code you use? And make a PullRequest if you have different code.
Author
Owner

@gregoks commented on GitHub (Nov 20, 2019):

@StefH looks ok. did the error recreated when you ran your code?

@gregoks commented on GitHub (Nov 20, 2019): @StefH looks ok. did the error recreated when you ran your code?
Author
Owner

@StefH commented on GitHub (Nov 20, 2019):

I had no errors when running this example code, but you can try yourself and maybe use your own logger?

@StefH commented on GitHub (Nov 20, 2019): I had no errors when running this example code, but you can try yourself and maybe use your own logger?
Author
Owner

@StefH commented on GitHub (Jul 7, 2020):

@gregoks
Did you have any luck solving this issue yet ?

@StefH commented on GitHub (Jul 7, 2020): @gregoks Did you have any luck solving this issue yet ?
Author
Owner

@gregoks commented on GitHub (Jul 10, 2020):

Sorry, havent got around to handle it. Im not sure it still happens though

@gregoks commented on GitHub (Jul 10, 2020): Sorry, havent got around to handle it. Im not sure it still happens though
Author
Owner

@StefH commented on GitHub (Sep 6, 2020):

Hello @gregoks

I'm closing this issue for now. It could be that this is related to https://github.com/WireMock-Net/WireMock.Net/issues/478, so please take a look at that issue + solution.

In case you encounter this again, please raise a new issue.

@StefH commented on GitHub (Sep 6, 2020): Hello @gregoks I'm closing this issue for now. It could be that this is related to https://github.com/WireMock-Net/WireMock.Net/issues/478, so please take a look at that issue + solution. In case you encounter this again, please raise a new issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#202