Closed andreas-schilling closed 6 years ago
@Bean
MongoClientSettingsBuilderCustomizer clientSettingsBuilderCustomizer() {
return builder -> builder.streamFactoryFactory(NettyStreamFactoryFactory.builder().build());
}
is required to use SSL.
Yes, sure, that's what I was referring to :-) Background of this issue is whether this should be found in the documentation or whether it already is in there and I just missed it.
Documentation would certainly help but this seems quite a complicated way to get SSL support. I wonder if we can detect netty and apply the configuration automatically?
@mp911de I see you commented on the stackoverflow.com issue, any advice on this?
Isn't it even that you can go as far as stopping the configuration process when your MongoDB connection requires SSL and there's no netty? If I understood it correctly it's mandatory. In our case the application started and any request towards the database failed due to SSL.
I'd suggest to always configure the reactive MongoDB driver with a NettyStreamFactoryFactory
bean if netty is available, not limiting to SSL. Along with this change, we get more control over threading as the current driver version has no means to control how many threads get used.
Regarding the SSL requirement, I'm a bit torn. It's a requirement of the driver. Propagating this assumption into Spring Boot creates a dependency that might become invalid with a newer MongoDB driver version. Spring Boot would be required to monitor that assumption for a future change which does not scale well.
Thanks @mp911de. Let's use Netty automatically when we can and add a note to the docs that you need it for SSL.
I've requalified this documentation issue by creating a separate issue (#11526) for the mongodb driver configuration change.
Question
Am I right that there is no proper information about using reactive Spring Data MongoDB with SSL? I stumbled upon this problem and the best I could find was this information: https://stackoverflow.com/questions/43310037/cannot-connect-to-mongodb-using-spring-data-reactive-and-spring-boot-2-0 With some more information from the MongoDB (not Spring) documentation I found out it's actually quite simple to make this work using the
MongoClientSettingsBuilderCustomizer
. It might be a tiny bit, but it's quite crucial for any production deployment, e.g. on CF.Enhancement
A small section in the documentation could help alot already. If I didn't just miss it somewhere I can also provide that snippet as a PR.