|
The implementation we've chosen is more general than just adding support for KeepAlive. We've added a SocketConfigurator hook that gets called when a socket is created, and you can configure the Socket anyway you want in your callback.
For example, to set KeepAlive to true, you could use the hook this way:
var url = new MongoUrl("mongodb://localhost");
|
var clientSettings = MongoClientSettings.FromUrl(url);
|
Action<Socket> socketConfigurator = s => s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
|
clientSettings.ClusterConfigurator = cb => cb.ConfigureTcp(tcp => tcp.With(socketConfigurator: socketConfigurator));
|
var client = new MongoClient(clientSettings);
|
|