-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Connectivity
-
None
Previously we didn't add a reason field into ConnectionClosedEvent because this event is called from Dispose method and we didn't have a way to determine for what reason this method has been called.
But as we found in the scope of https://jira.mongodb.org/browse/HELP-18973, this value can be helpful for some connectivity investigations.
Two options which were discussed in the slack:
- Add a new Close(ConnectionClosedReason reason) method which will contain triggering event logic and Dispose logic. The disadvantage of this way (additionally to having Close and Dispose methods for the same class) is that it's unclear whether Dispose method should still have triggering events or no. If yes, we still can potentially have the same issue with empty reason field as we have now, if no - then we can have the potential situation without ConnectionClosedEvent at all.
- Investigate how this logic works in java. As far as I can see they trigger the ConnectionClosedEvent before calling stream.Close (afaik, this is an equivalent of stream.Dispose in c#): https://github.com/mongodb/mongo-java-driver/blob/91e670f86303121c7afe68145d3ca5d341079506/driver-core/src/main/com/mongodb/internal/connection/DefaultConnectionPool.java#L598