Mongo connection is failing

I have…

  • [x] Checked the logs and have uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [x] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

The Mongodb connection is failing. I tried to restart mongodb and webapp from Azure.

Expected behavior

Connect to Squidex normally

Minimal reproduction of the problem

Environment

  • [ ] Self hosted with docker
  • [x] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: [VERSION]

Browser:

  • [x] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:
Getting this error in log files:
{
2021-05-12T09:23:37.371129762Z “logLevel”: “Error”,
2021-05-12T09:23:37.371137263Z “message”: “QueueWorkItem was called on a non-null context [SystemTarget: S127.0.0.1:11111:358507384*stg/13/0000000d@S0000000d] but there is no valid WorkItemGroup for it.”,
2021-05-12T09:23:37.371142763Z “eventId”: {
2021-05-12T09:23:37.371147363Z “id”: 101231
2021-05-12T09:23:37.371152263Z }

Log file:
2021-05-12T09:23:06.383222479Z “app”: {
2021-05-12T09:23:06.383225679Z “name”: “Squidex”,
2021-05-12T09:23:06.383228879Z “version”: “5.4.0.0”,
2021-05-12T09:23:06.383232079Z “sessionId”: “3359323f-77e3-4e5b-832f-2f6f09776f83”
2021-05-12T09:23:06.383235379Z },
2021-05-12T09:23:06.383238479Z “timestamp”: “2021-05-12T09:23:06Z”
2021-05-12T09:23:06.383241779Z }
2021-05-12T09:23:06.383244979Z
2021-05-12T09:23:07.260508166Z {
2021-05-12T09:23:07.260574867Z “logLevel”: “Information”,
2021-05-12T09:23:07.260581367Z “initializedSystem”: “Squidex.Assets.AzureBlobAssetStore”,
2021-05-12T09:23:07.260585867Z “app”: {
2021-05-12T09:23:07.260589967Z “name”: “Squidex”,
2021-05-12T09:23:07.260606167Z “version”: “5.4.0.0”,
2021-05-12T09:23:07.260617968Z “sessionId”: “3359323f-77e3-4e5b-832f-2f6f09776f83”
2021-05-12T09:23:07.260622768Z },
2021-05-12T09:23:07.260626868Z “timestamp”: “2021-05-12T09:23:07Z”
2021-05-12T09:23:07.260631768Z }
2021-05-12T09:23:07.260635768Z
2021-05-12T09:23:37.371059161Z {
2021-05-12T09:23:37.371129762Z “logLevel”: “Error”,
2021-05-12T09:23:37.371137263Z “message”: “QueueWorkItem was called on a non-null context [SystemTarget: S127.0.0.1:11111:358507384*stg/13/0000000d@S0000000d] but there is no valid WorkItemGroup for it.”,
2021-05-12T09:23:37.371142763Z “eventId”: {
2021-05-12T09:23:37.371147363Z “id”: 101231
2021-05-12T09:23:37.371152263Z },
2021-05-12T09:23:37.371156763Z “app”: {
2021-05-12T09:23:37.371702276Z “name”: “Squidex”,
2021-05-12T09:23:37.371716276Z “version”: “5.4.0.0”,
2021-05-12T09:23:37.371721476Z “sessionId”: “3359323f-77e3-4e5b-832f-2f6f09776f83”
2021-05-12T09:23:37.371726476Z },
2021-05-12T09:23:37.371756577Z “timestamp”: “2021-05-12T09:23:37Z”,
2021-05-12T09:23:37.371762977Z “category”: “Orleans.Runtime.Scheduler.OrleansTaskScheduler”
2021-05-12T09:23:37.371768077Z }
2021-05-12T09:23:37.371772477Z
2021-05-12T09:23:37.411029982Z Unhandled exception. Squidex.Infrastructure.ConfigurationException: MongoDb connection failed to connect to database Squidex
2021-05-12T09:23:37.411059883Z —> System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : “1”, ConnectionMode : “Automatic”, Type : “Unknown”, State : “Disconnected”, Servers : [{ ServerId: “{ ClusterId : 1, EndPoint : “Unspecified/surfacelove-new-dev-mongodb.westeurope.azurecontainer.io:27017” }”, EndPoint: “Unspecified/surfacelove-new-dev-mongodb.westeurope.azurecontainer.io:27017”, ReasonChanged: “Heartbeat”, State: “Disconnected”, ServerVersion: , TopologyVersion: , Type: “Unknown”, HeartbeatException: “MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
2021-05-12T09:23:37.411069083Z —> MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server.
2021-05-12T09:23:37.411073683Z —> System.TimeoutException: The operation has timed out.
2021-05-12T09:23:37.411084183Z at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, TimeSpan timeout, CancellationToken cancellationToken)
2021-05-12T09:23:37.411089483Z at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytesAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, TimeSpan timeout, CancellationToken cancellationToken)
2021-05-12T09:23:37.411104584Z at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync(CancellationToken cancellationToken)
2021-05-12T09:23:37.411108984Z — End of inner exception stack trace —
2021-05-12T09:23:37.411112684Z at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessageAsync(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
2021-05-12T09:23:37.411116884Z at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken) 2021-05-12T09:23:37.411121684Z at MongoDB.Driver.Core.Connections.IsMasterHelper.GetResultAsync(IConnection connection, CommandWireProtocol1 isMasterProtocol, CancellationToken cancellationToken)
2021-05-12T09:23:37.411125684Z at MongoDB.Driver.Core.Connections.ConnectionInitializer.InitializeConnectionAsync(IConnection connection, CancellationToken cancellationToken)
2021-05-12T09:23:37.411129884Z at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
2021-05-12T09:23:37.411133884Z — End of inner exception stack trace —
2021-05-12T09:23:37.411137585Z at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
2021-05-12T09:23:37.411141485Z at MongoDB.Driver.Core.Servers.ServerMonitor.InitializeConnectionAsync(CancellationToken cancellationToken)
2021-05-12T09:23:37.411145385Z at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)”, LastHeartbeatTimestamp: “2021-05-12T09:23:36.3114319Z”, LastUpdateTimestamp: “2021-05-12T09:23:36.3114323Z” }] }.
2021-05-12T09:23:37.411149785Z at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)
2021-05-12T09:23:37.411153585Z at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)
2021-05-12T09:23:37.411157485Z at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedAsync(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken)
2021-05-12T09:23:37.411161585Z at MongoDB.Driver.Core.Clusters.Cluster.SelectServerAsync(IServerSelector selector, CancellationToken cancellationToken)
2021-05-12T09:23:37.411165485Z at MongoDB.Driver.MongoClient.AreSessionsSupportedAfterSeverSelctionAsync(CancellationToken cancellationToken)
2021-05-12T09:23:37.411169285Z at MongoDB.Driver.MongoClient.AreSessionsSupportedAsync(CancellationToken cancellationToken)
2021-05-12T09:23:37.411173285Z at MongoDB.Driver.MongoClient.StartImplicitSessionAsync(CancellationToken cancellationToken)
2021-05-12T09:23:37.411177085Z at MongoDB.Driver.MongoCollectionImpl1.UsingImplicitSessionAsync[TResult](Func2 funcAsync, CancellationToken cancellationToken)
2021-05-12T09:23:37.411181386Z at Squidex.Infrastructure.EventSourcing.MongoEventStore.SetupCollectionAsync(IMongoCollection1 collection, CancellationToken ct) in /src/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs:line 57 2021-05-12T09:23:37.411188986Z at Squidex.Infrastructure.MongoDb.MongoRepositoryBase1.InitializeAsync(CancellationToken ct) in /src/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs:line 111
2021-05-12T09:23:37.411193286Z — End of inner exception stack trace —
2021-05-12T09:23:37.411197286Z at Squidex.Infrastructure.MongoDb.MongoRepositoryBase`1.InitializeAsync(CancellationToken ct) in /src/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs:line 115
2021-05-12T09:23:37.411201386Z at Squidex.Config.Startup.InitializerHost.StartAsync(ISemanticLog log, CancellationToken ct) in /src/src/Squidex/Config/Startup/InitializerHost.cs:line 31
2021-05-12T09:23:37.411205286Z at Squidex.Config.Startup.SafeHostedService.StartAsync(CancellationToken cancellationToken) in /src/src/Squidex/Config/Startup/SafeHostedService.cs:line 27
2021-05-12T09:23:37.411209286Z at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
2021-05-12T09:23:37.411213086Z at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2021-05-12T09:23:37.411216886Z at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2021-05-12T09:23:37.411220786Z at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
2021-05-12T09:23:37.411224787Z at Squidex.Program.Main(String[] args) in /src/src/Squidex/Program.cs:line 23

I am not sure how I can help you there. It is definitely not a bug, more a hosting issue and I have too few information to help you there. Have you checked the MongoDB status?

strange! the mongodb is connected and working again. I dont know why this problem is reoccuring and how it is to be fixed. How can i make sure this doesnt happen again. Please guide.
This is the connections we have for cms webapp. We are using secret key vault
[
{
“name”: “ASSETSTORE__AZUREBLOB__CONNECTIONSTRING”,
“value”: “@Microsoft.KeyVault(VaultName=SurfaceLove-New-DEV;SecretName=ConnectionStrings–StorageAccount;SecretVersion=)”,
“slotSetting”: false
},
{
“name”: “ASSETSTORE__AZUREBLOB__CONTAINERNAME”,
“value”: “cms-assets”,
“slotSetting”: false
},
{
“name”: “ASSETSTORE__TYPE”,
“value”: “AzureBlob”,
“slotSetting”: false
},
{
“name”: “EVENTSTORE__MONGODB__CONFIGURATION”,
“value”: “@Microsoft.KeyVault(VaultName=SurfaceLove-New-DEV;SecretName=ConnectionStrings–MongoDB;SecretVersion=)”,
“slotSetting”: false
},
{
“name”: “IDENTITY__ADMINEMAIL”,
“value”: “@Microsoft.KeyVault(VaultName=SurfaceLove-New-DEV;SecretName=CMSAdminLogin;SecretVersion=)”,
“slotSetting”: false
},
{
“name”: “IDENTITY__ADMINPASSWORD”,
“value”: “@Microsoft.KeyVault(VaultName=SurfaceLove-New-DEV;SecretName=CMSAdminLoginPassword;SecretVersion=)”,
“slotSetting”: false
},
{
“name”: “IDENTITY__ADMINRECREATE”,
“value”: “true”,
“slotSetting”: false
},
{
“name”: “IDENTITY__GITHUBCLIENT”,
“value”: “”,
“slotSetting”: false
},
{
“name”: “IDENTITY__GITHUBSECRET”,
“value”: “”,
“slotSetting”: false
},
{
“name”: “IDENTITY__GOOGLECLIENT”,
“value”: “”,
“slotSetting”: false
},
{
“name”: “IDENTITY__GOOGLESECRET”,
“value”: “”,
“slotSetting”: false
},
{
“name”: “IDENTITY__MICROSOFTCLIENT”,
“value”: “”,
“slotSetting”: false
},
{
“name”: “IDENTITY__MICROSOFTSECRET”,
“value”: “”,
“slotSetting”: false
},
{
“name”: “IDENTITY__oidcAuthority”,
“value”: “https://login.microsoftonline.com/7e34a101-4f3e-45c7-943e-1bfeb9530099/v2.0”,
“slotSetting”: false
},
{
“name”: “IDENTITY__oidcClient”,
“value”: “@Microsoft.KeyVault(VaultName=SurfaceLove-New-DEV;SecretName=CmsOIDCClientId;SecretVersion=)”,
“slotSetting”: false
},
{
“name”: “IDENTITY__oidcName”,
“value”: “Microsoft”,
“slotSetting”: false
},
{
“name”: “IDENTITY__oidcSecret”,
“value”: “@Microsoft.KeyVault(VaultName=SurfaceLove-New-DEV;SecretName=CmsOIDCClientSecret;SecretVersion=)”,
“slotSetting”: false
},
{
“name”: “STORE__MONGODB__CONFIGURATION”,
“value”: “@Microsoft.KeyVault(VaultName=SurfaceLove-New-DEV;SecretName=ConnectionStrings–MongoDB;SecretVersion=)”,
“slotSetting”: false
},
{
“name”: “URLS__BASEURL”,
“value”: “https://surfacelove-new-dev-cms.azurewebsites.net”,
“slotSetting”: false
}
]

I need more infos about your deployment before I can help. Where do you host MongoDB? Just assume that I have no idea about your hosting setup.