[SOLVED] MongoAuthenticationException: Server sent an invalid nonce

When trying to run 4.7.3 in docker I get the following. Version 4.6.0 is working fine with the same connection string.

2020-10-08T07:53:54.899563540Z Unhandled exception. Squidex.Infrastructure.Migrations.MigrationFailedException: Failed to run migration 'Migrations.Migrations.StopEventConsumers'
2020-10-08T07:53:54.899590243Z  ---> Squidex.Infrastructure.Orleans.OrleansWrapperException: Wrapping exception of type MongoDB.Driver.MongoAuthenticationException, because original exception is not serialized.
2020-10-08T07:53:54.899602544Z 
2020-10-08T07:53:54.899606444Z Original exception:
2020-10-08T07:53:54.899610145Z MongoDB.Driver.MongoAuthenticationException: Server sent an invalid nonce.
2020-10-08T07:53:54.899614345Z    at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
2020-10-08T07:53:54.899618045Z    at MongoDB.Driver.Core.Servers.Server.GetChannelAsync(CancellationToken cancellationToken)
2020-10-08T07:53:54.899621746Z    at MongoDB.Driver.Core.Operations.RetryableReadContext.InitializeAsync(CancellationToken cancellationToken)
2020-10-08T07:53:54.899625446Z    at MongoDB.Driver.Core.Operations.RetryableReadContext.CreateAsync(IReadBinding binding, Boolean retryRequested, CancellationToken cancellationToken)
2020-10-08T07:53:54.899629146Z    at MongoDB.Driver.Core.Operations.FindOperation`1.ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken)
2020-10-08T07:53:54.899632947Z    at MongoDB.Driver.OperationExecutor.ExecuteReadOperationAsync[TResult](IReadBinding binding, IReadOperation`1 operation, CancellationToken cancellationToken)
2020-10-08T07:53:54.899636847Z    at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperationAsync[TResult](IClientSessionHandle session, IReadOperation`1 operation, ReadPreference readPreference, CancellationToken cancellationToken)
2020-10-08T07:53:54.899640747Z    at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken)
2020-10-08T07:53:54.899644448Z    at MongoDB.Driver.IAsyncCursorSourceExtensions.FirstOrDefaultAsync[TDocument](IAsyncCursorSource`1 source, CancellationToken cancellationToken)
2020-10-08T07:53:54.899648148Z    at Squidex.Infrastructure.States.MongoSnapshotStore`2.ReadAsync(TKey key) in /src/src/Squidex.Infrastructure.MongoDb/States/MongoSnapshotStore.cs:line 49
2020-10-08T07:53:54.899664249Z    at Squidex.Infrastructure.States.Persistence`2.ReadSnapshotAsync() in /src/src/Squidex.Infrastructure/States/Persistence{TSnapshot,TKey}.cs:line 89
2020-10-08T07:53:54.899669050Z    at Squidex.Infrastructure.States.Persistence`2.ReadAsync(Int64 expectedVersion) in /src/src/Squidex.Infrastructure/States/Persistence{TSnapshot,TKey}.cs:line 68
2020-10-08T07:53:54.899673150Z    at Orleans.LifecycleSubject.OnStart(CancellationToken ct)
2020-10-08T07:53:54.899676750Z    at Orleans.Runtime.Catalog.CallGrainActivate(ActivationData activation, Dictionary`2 requestContextData)
2020-10-08T07:53:54.899680451Z    at Orleans.Runtime.Scheduler.AsyncClosureWorkItem.Execute()
2020-10-08T07:53:54.899684051Z    at Orleans.Runtime.Catalog.InitActivation(ActivationData activation, Dictionary`2 requestContextData)
2020-10-08T07:53:54.899687751Z    at Orleans.Runtime.Catalog.InitActivation(ActivationData activation, Dictionary`2 requestContextData)
2020-10-08T07:53:54.899691352Z    at Orleans.Internal.OrleansTaskExtentions.<ToTypedTask>g__ConvertAsync|4_0[T](Task`1 asyncTask)
2020-10-08T07:53:54.899695352Z    at Squidex.Infrastructure.EventSourcing.Grains.OrleansCodeGenEventConsumerManagerGrainMethodInvoker.Invoke(IAddressable grain, InvokeMethodRequest request) in /src/src/Squidex.Infrastructure/obj/Release/netcoreapp3.1/Squidex.Infrastructure.orleans.g.cs:line 327
2020-10-08T07:53:54.899699852Z    at Orleans.Runtime.GrainMethodInvoker.Invoke()
2020-10-08T07:53:54.899703353Z    at Squidex.Infrastructure.Orleans.StateFilter.Invoke(IIncomingGrainCallContext context) in /src/src/Squidex.Infrastructure/Orleans/StateFilter.cs:line 31
2020-10-08T07:53:54.899707153Z    at Orleans.Runtime.GrainMethodInvoker.Invoke()
2020-10-08T07:53:54.899710753Z    at Squidex.Infrastructure.Orleans.LocalCacheFilter.Invoke(IIncomingGrainCallContext context) in /src/src/Squidex.Infrastructure/Orleans/LocalCacheFilter.cs:line 32
2020-10-08T07:53:54.899714554Z    at Orleans.Runtime.GrainMethodInvoker.Invoke()
2020-10-08T07:53:54.899718054Z    at Orleans.Runtime.GrainMethodInvoker.Invoke()
2020-10-08T07:53:54.899721554Z    at Squidex.Infrastructure.Orleans.ExceptionWrapperFilter.Invoke(IIncomingGrainCallContext context) in /src/src/Squidex.Infrastructure/Orleans/ExceptionWrapperFilter.cs:line 20
2020-10-08T07:53:54.899725455Z 
2020-10-08T07:53:54.899728855Z    at Squidex.Infrastructure.Orleans.ExceptionWrapperFilter.Invoke(IIncomingGrainCallContext context) in /src/src/Squidex.Infrastructure/Orleans/ExceptionWrapperFilter.cs:line 32
2020-10-08T07:53:54.899732655Z    at Orleans.Runtime.GrainMethodInvoker.Invoke()
2020-10-08T07:53:54.899736156Z    at Squidex.Infrastructure.Orleans.LoggingFilter.Invoke(IIncomingGrainCallContext context) in /src/src/Squidex.Infrastructure/Orleans/LoggingFilter.cs:line 30
2020-10-08T07:53:54.899740056Z    at Orleans.Runtime.GrainMethodInvoker.Invoke()
2020-10-08T07:53:54.899743956Z    at OrleansDashboard.Metrics.GrainProfilerFilter.Invoke(IIncomingGrainCallContext context)
2020-10-08T07:53:54.899747657Z    at Orleans.Runtime.GrainMethodInvoker.Invoke()
2020-10-08T07:53:54.899754157Z    at Orleans.Runtime.InsideRuntimeClient.Invoke(IAddressable target, IInvokable invokable, Message message)
2020-10-08T07:53:54.899757958Z    at Squidex.Infrastructure.Migrations.Migrator.MigrateAsync(CancellationToken ct) in /src/src/Squidex.Infrastructure/Migrations/Migrator.cs:line 78
2020-10-08T07:53:54.899761758Z    --- End of inner exception stack trace ---
2020-10-08T07:53:54.899765158Z    at Squidex.Infrastructure.Migrations.Migrator.MigrateAsync(CancellationToken ct) in /src/src/Squidex.Infrastructure/Migrations/Migrator.cs:line 88
2020-10-08T07:53:54.899768959Z    at Squidex.Infrastructure.Migrations.Migrator.MigrateAsync(CancellationToken ct) in /src/src/Squidex.Infrastructure/Migrations/Migrator.cs:line 97
2020-10-08T07:53:54.899772659Z    at Squidex.Config.Startup.SafeHostedService.StartAsync(CancellationToken cancellationToken) in /src/src/Squidex/Config/Startup/SafeHostedService.cs:line 29
2020-10-08T07:53:54.899776459Z    at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
2020-10-08T07:53:54.899780060Z    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2020-10-08T07:53:54.899783760Z    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2020-10-08T07:53:54.899787460Z    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
2020-10-08T07:53:54.906380844Z    at Squidex.Program.Main(String[] args) in /src/src/Squidex/Program.cs:line 24

Which MongoDB version do you use? Perhaps the driver is not compatible.

It seems to be a driver bug: https://jira.mongodb.org/browse/CSHARP-3196

I can provide a fix today

I have deployed a 4.7.4, but it contains a stupid spelling error, when creating a new app. Nothing serious, but I will also release a 4.7.5 today.

1 Like

I’ll test 4.7.4 and let you know

It’s working now! Thanks

1 Like