-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.5
-
Component/s: Configuration, GridFS
-
None
-
Environment:Net core, ubuntu 16.04, mongodb 3.6.2 version
builder.Register(ctx => new MongoClient(_mongoClientSettings)) .As<IMongoClient>() .SingleInstance(); builder.Register(ctx => { var client = ctx.Resolve<IMongoClient>(); return client.GetDatabase(_databaseName); }).As<IMongoDatabase>().SingleInstance(); builder.Register( ctx => new GridFSBucket<Guid>( ctx.Resolve<IMongoDatabase>(), new GridFSBucketOptions { BucketName = "Avatars" })) .As<IGridFSBucket<Guid>>() .SingleInstance();
clientSettings.ClusterConfigurator = clusterBuilder => { clusterBuilder.Subscribe<ClusterSelectingServerFailedEvent>(evnt => { var logger = loggerFactory.CreateLogger<MongoModule>(); logger.LogCritical("Cluster selecting server failed! {@Event}", evnt); }) // .Subscribe<CommandFailedEvent>(evnt => // { // var logger = loggerFactory.CreateLogger<MongoModule>(); // logger.LogWarning("Command failed! {@Event}", evnt); // }) .Subscribe<ConnectionFailedEvent>(evnt => { var logger = loggerFactory.CreateLogger<MongoModule>(); logger.LogCritical("Connection failed! {@Event}", evnt); }) .Subscribe<ConnectionOpeningFailedEvent>(evnt => { var logger = loggerFactory.CreateLogger<MongoModule>(); logger.LogCritical("Connection opening failed! {@Event}", evnt); }) .Subscribe<ConnectionPoolCheckingOutConnectionFailedEvent>(evnt => { var logger = loggerFactory.CreateLogger<MongoModule>(); logger.LogCritical("Connection pool checking out connection failed! {@Event}", evnt); }) .Subscribe<ConnectionReceivingMessageFailedEvent>(evnt => { var logger = loggerFactory.CreateLogger<MongoModule>(); logger.LogWarning("Connection receiving message failed! {@Event}", evnt); }) .Subscribe<ConnectionSendingMessagesFailedEvent>(evnt => { var logger = loggerFactory.CreateLogger<MongoModule>(); logger.LogWarning("Connection sending messages failed! {@Event}", evnt); }) .Subscribe<ServerHeartbeatFailedEvent>(evnt => { var logger = loggerFactory.CreateLogger<MongoModule>(); logger.LogCritical("Server heart beat failed! {@Event}", evnt); }) .Subscribe<ServerClosedEvent>(evnt => { var logger = loggerFactory.CreateLogger<MongoModule>(); logger.LogCritical("Server closed! {@Event}", evnt); }) .Subscribe<ServerOpenedEvent>(evnt => { var logger = loggerFactory.CreateLogger<MongoModule>(); logger.LogInformation("Server opened! {@Event}", evnt); }) .Subscribe<ConnectionOpenedEvent>(evnt => { var logger = loggerFactory.CreateLogger<MongoModule>(); logger.LogInformation("Connection opened! {@Event}", evnt); }); };
If subscription wil be uncomment, any upload operation will be raise CommandFailedEvent with messages:
`Collection Avatars.files does not exist`
`Collection Avatars.chunks does not exist`
After explicitly collections creation all work as expected.