question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ENVCHANGE Token is not decoded properly for Routing type

See original GitHub issue

Current 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:closed
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
lhaatveitcommented, Jan 27, 2020

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 update hostNameInCertificate based on the new server name. If the current rule is *.domain, and you are redirected to some.sub.domain, then the new hostNameInCertificate will be *.sub.domain.

1reaction
aartiescommented, Jan 21, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

[MS-TDS]: ENVCHANGE - Microsoft Learn
Token Stream Name: ENVCHANGE Token Stream Function: A notification of ... Type 20 (Routing) is sent in response to a LOGIN7 message when...
Read more >
[MS-TDS-Diff]: Tabular Data Stream Protocol - NET
Microsoft does not claim any trade secret rights in this ... because the length of its associated data is encoded in the token...
Read more >
MTA Deployment Descriptor Syntax - SAP Help Portal
check-deploy-id: true; dependency-type: hard; health-check-type: none. None. Portal content activation. com.sap.html5.application-content. CF. no-route: ...
Read more >
com.microsoft.sqlserver.jdbc.SQLServerConnection Maven ...
The API javadoc for JDBC API methods that this class implements are not ... those changed due to routing ENVCHANGE token resetNonRoutingEnvchangeValues(); ...
Read more >
[Ms tds] - SlideShare
the client does not, then a value of 0x0000 SHOULD be sent to the server. Message type Client or server message Token stream?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found