We had the issue with various versions of spring boot 2 (as per Prabhats), but have recently migrated to Spring 3.0, which pulls in version 4.8.0 of the following:
mongodb-driver-core
mongodb-driver-legacy
mongodb-driver-reactivestreams
mongodb-driver-sync
We pretty much see this exception every day (completely intermittent amongst thousands of transactions).
2022-12-28 06:09:03.334 GMT
Caused by: com.mongodb.MongoSocketWriteException: Exception sending message
2022-12-28 06:09:03.334 GMT
at com.mongodb.internal.connection.InternalStreamConnection.translateWriteException(InternalStreamConnection.java:687) ~[mongodb-driver-core-4.8.0.jar!/:na]
2022-12-28 06:09:03.334 GMT
at com.mongodb.internal.connection.InternalStreamConnection.access$700(InternalStreamConnection.java:89) ~[mongodb-driver-core-4.8.0.jar!/:na]
2022-12-28 06:09:03.334 GMT
at com.mongodb.internal.connection.InternalStreamConnection$3.failed(InternalStreamConnection.java:604) ~[mongodb-driver-core-4.8.0.jar!/:na]
2022-12-28 06:09:03.334 GMT
at com.mongodb.connection.netty.NettyStream$2.operationComplete(NettyStream.java:256) ~[mongodb-driver-core-4.8.0.jar!/:na]
2022-12-28 06:09:03.335 GMT
Caused by: io.netty.channel.StacklessClosedChannelException: null
2022-12-28 06:09:03.335 GMT
at io.netty.channel.AbstractChannel$AbstractUnsafe.write(Object, ChannelPromise)(Unknown Source) ~[netty-transport-4.1.85.Final.jar!/:4.1.85.Final]
2022-12-28 06:09:03.335 GMT
Caused by: java.io.IOException: Broken pipe
2022-12-28 06:09:03.335 GMT
at java.base/sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:na]
2022-12-28 06:09:03.335 GMT
at java.base/sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:62) ~[na:na]
2022-12-28 06:09:03.335 GMT
at java.base/sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:137) ~[na:na]
2022-12-28 06:09:03.335 GMT
at java.base/sun.nio.ch.IOUtil.write(IOUtil.java:81) ~[na:na]