Orchard Core 2.0.2 - Error after some calls to the API endpoints: Status:BadRequest Error: {\"status\":\"Error: - The configured user limit (128) on the number of inotify instances has been reached, or the per-process limit on the number of open file descriptors has been reached.\",\"item\":null}
#17231
-
Hi everyone, in my Books microservice, which is a headless Orchard Core 2.0.2 app (I need to update it to the latest), I have some API endpoints used to retrieve books. However, after a few calls from the frontend, Orchard Core stops working and throws this error:
To make it working again I need to recreate the Docker container. After searching online, it seems this issue is caused by the Does anyone know how I can set Thank you Below is my var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddOrchardCms()
.ConfigureServices(services =>
{
// ------- Here I get the appsettings configuration because I need it in the Handler part
ConfigurationModel config = builder.Configuration.Get<ConfigurationModel>();
if (config == null)
{
throw new Exception("Was impossible to retrieve the appsettings.json configuration, that are necessary to instantiate the Handler classes. Please check the appsettings file.");
}
services.AddHttpClient();
#region Add Handlers
// Register BookHandler with dependencies injected
services.AddScoped<IBookHandler>(sp =>
{
return new BookHandler(
config.ExternalServices.UsersMicroserviceBaseUrl,
config.ExternalServices.ErpService,
sp.GetRequiredService<ILogger<BookHandler>>());
});
#endregion
});
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseOrchardCore();
// Remove in the API response the header "X-Powered-By: OrchardCore"
app.UsePoweredByOrchardCore(enabled: false);
app.Run(); |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 15 replies
-
I’m not sure if overwriting the appsettings and reloading them in var builder = WebApplication.CreateBuilder(args);
// builder.Configuration.Sources.Clear(); // Remove current configuration sources - REMOVED because Docker was returning error with this
builder.Configuration
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false) // Add the appsettings.json file without reloadOnChange
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: false) // As last configuration load the one based on the Environment
.AddEnvironmentVariables();
builder.Services
.AddOrchardCms()
.ConfigureServices(services =>
{
ConfigurationModel config = builder.Configuration.Get<ConfigurationModel>();
if (config == null)
{
throw new Exception("Was impossible to retrieve the appsettings.json configuration, that are necessary to instantiate the Handler classes. Please check the appsettings file.");
}
[...]
|
Beta Was this translation helpful? Give feedback.
-
You could try increasing the limit of the container so it's higher than 128. Are you running lots of tenants on the server where you encounter this problem? Does your application cause lots of tenant reloads? You should write the application logs to a mounted volume so they are not lost during a crash and then check out the app logs for more clues to see why there are lots of file change notifications are happening. Does this happen with a specific tenant or all tenants? |
Beta Was this translation helpful? Give feedback.
-
have you tried using
|
Beta Was this translation helpful? Give feedback.
-
As suggested here: You should increase the fs.inotify.max_user_instances in /etc/sysctl.conf by running this command: echo fs.inotify.max_user_instances=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p I could repro the issue under latest Ubuntu 24.something. This also can be fixed by using environment vars. See stackoverflow. This is not related to Orchard Core but to ASP.NET itself. |
Beta Was this translation helpful? Give feedback.
Hi @weirdyang, it seems that the problem was related to my implementation of the
HttpClientFactory
class, where it probably wasn't able to dispose the old sockets.Now, instead of using
HttpClientFactory
, I'm using a singleHttpClient
, and it seems to be working correctly 🤞I will update this post if the problem reappears.
Thank you all for your support 😊