@@ -74,6 +74,11 @@ class Features
7474 SERVER_TOO_OLD = "Server at (%s) reports wire version (%s), but this version of the Ruby driver " +
7575 "requires at least (%s)."
7676
77+ # Warning message if the server version is deprecated.
78+ SERVER_DEPRECATED = 'Server at (%s) reports wire version (%s), but support for that wire version ' \
79+ 'is deprecated and will be removed in a future version of the Ruby driver. ' \
80+ 'Please upgrade your MongoDB server to a newer version soon.'
81+
7782 # Error message if the driver is too old for the version of the server.
7883 #
7984 # @since 2.5.0
@@ -83,7 +88,20 @@ class Features
8388 # The wire protocol versions that this version of the driver supports.
8489 #
8590 # @since 2.0.0
86- DRIVER_WIRE_VERSIONS = ( 6 ..25 ) . freeze
91+ DRIVER_WIRE_VERSIONS = 6 ..25
92+
93+ # The wire protocol versions that are deprecated in this version of the
94+ # driver. Support for these versions will be removed in the future.
95+ #
96+ # If there are multiple currently-deprecated wire versions, this should
97+ # be set to a range of those versions.
98+ #
99+ # If there is only a single currently-deprecated wire version, this should
100+ # be set to a range where the min and max are the same value.
101+ #
102+ # If there are no currently-deprecated wire versions, this should be
103+ # set to an empty array.
104+ DEPRECATED_WIRE_VERSIONS = 6 ..6
87105
88106 # Create the methods for each mapping to tell if they are supported.
89107 #
@@ -131,20 +149,21 @@ def initialize(server_wire_versions, address = nil)
131149 end
132150
133151 # Check that there is an overlap between the driver supported wire
134- # version range and the server wire version range.
135- #
136- # @example Verify the wire version overlap.
137- # features.check_driver_support!
152+ # version range and the server wire version range. Also checks to see
153+ # if the server is using a deprecated wire version.
138154 #
139155 # @raise [ Error::UnsupportedFeatures ] If the wire version range is
140156 # not covered by the driver.
141- #
142- # @since 2.5.1
143157 def check_driver_support!
144- if DRIVER_WIRE_VERSIONS . min > @server_wire_versions . max
158+ if DEPRECATED_WIRE_VERSIONS . include? ( @server_wire_versions . max )
159+ feature = "wire_version:#{ @address } "
160+ Mongo ::Deprecations . warn ( feature , SERVER_DEPRECATED % [ @address , @server_wire_versions . max ] )
161+
162+ elsif DRIVER_WIRE_VERSIONS . min > @server_wire_versions . max
145163 raise Error ::UnsupportedFeatures . new ( SERVER_TOO_OLD % [ @address ,
146164 @server_wire_versions . max ,
147165 DRIVER_WIRE_VERSIONS . min ] )
166+
148167 elsif DRIVER_WIRE_VERSIONS . max < @server_wire_versions . min
149168 raise Error ::UnsupportedFeatures . new ( DRIVER_TOO_OLD % [ @address ,
150169 @server_wire_versions . min ,
0 commit comments