ENVCHANGE Token is not decoded properly for Routing type
See original GitHub issueCurrent implementation is throwing the following exception after handling LOGIN7 and Routing
ENVCHANGE token:
io.r2dbc.mssql.message.tds.ProtocolException: [4] Unable to decode unknown token type 0x00
at io.r2dbc.mssql.message.tds.ProtocolException.invalidTds(ProtocolException.java:96)
at io.r2dbc.mssql.message.token.Tabular.lambda$decodeFunction$0(Tabular.java:214)
at io.r2dbc.mssql.message.token.Tabular$TabularDecoder.decode(Tabular.java:376)
at io.r2dbc.mssql.message.token.Tabular.decode(Tabular.java:73)
at io.r2dbc.mssql.client.ConnectionState$3.lambda$decoder$1(ConnectionState.java:169)
at io.r2dbc.mssql.client.MessageDecoder.decode(MessageDecoder.java:45)
at io.r2dbc.mssql.client.StreamDecoder.withState(StreamDecoder.java:137)
at io.r2dbc.mssql.client.StreamDecoder.decode(StreamDecoder.java:109)
… <truncated>
Azure Sql Server instances seems to always send a Routing
ENVCHANGE token.
As per the Docs:
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-tds/2b3eb7e5-d43d-4d1b-bf4d-76b9e3afc791
Routing
ENVCHANGE token has a 2 byte OLD_VALUE (0x00 0x00). There is no old_value length (and from actual packets, it seems that old_value length is coming as 0 - which is causing the decode issue).
As per the mssql-jdbc repo, they are generally skipping to the end of message once the Routing new_value
is decoded. Plz refer to handling of ENVCHANGE_ROUTING
in mssql-jdbc code :
https://github.com/microsoft/mssql-jdbc/blob/master/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java#L3963
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
Have you read this part of the MS-TDS documentation? https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-tds/52851226-1211-46c8-ac50-6b7facd08fd9
It explains how the client should process the change in routing. I guess the routing feature itself may be used for several purposes.
Looking at the
mssql-jdbc
implementation, they only allow one redirect. Additionally, they updatehostNameInCertificate
based on the new server name. If the current rule is*.domain
, and you are redirected tosome.sub.domain
, then the newhostNameInCertificate
will be*.sub.domain
.Hi @mp911de , is there any update on this enhancement. I am trying to connect to Azure Sql database using spring boot and get similar error -Failed to obtain R2DBC Connection; nested exception is io.r2dbc.mssql.message.tds.ProtocolException: [4] Unable to decode unknown token type 0x00
Will difference in geo location of the servers impact the routing