You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm seeing some unexpected behavior during request timeouts while using the mssql library. I've traced the code down to the tedious module. Here's my scenario:
Open a connection to the database
Make a request to call a stored procedure
Get result, everything is good.
Go blackhole the database IP, so that no outgoing connections are allowed from my box to that IP.
Initiate another request.
After the configured requestTimeout (3 seconds), I see the request timeout triggering, which sets a 'SentAttention' state.
At this point, things just hang for a little bit, until what I assume is the socket KeepAlive notices that it can't get a response and triggers an error on the socket. At this point, the connection reports back something is wrong.
The unexpected bit is where the request timeout doesn't immediately trigger an error event on the connection and cancel the request, so that the mssql module can report back to the consumer that the request failed due to timeout. Is this behavior intentional? If so, can you explain a little bit of the rationale? Is there another way I should be setting a hard limit on request time? Thanks in advance.
If a TDS client implements the Client Request Timer and the timer times out, then the TDS client MUST send an Attention message to the server and enter the "Sent Attention" state.
So we're handling the request timeout correctly.
But on the next line, it says:
If a TDS client implements the Cancel Timer and the timer times out, then the TDS client MUST close the underlying connection, indicate the error to the upper layer, and enter the "Final State" state.
I also checked the code again to be sure. Although we have a cancelTimeout option, it's not honored anywhere. Adding the timeout should not be too hard.
@arthurschreiber Thanks for clarifying, that makes sense now. I'll take a crack at a PR if I have time, but it may not be for a little while. I'd love to see this feature if you have the bandwidth! In the mean time, we can just rely on the socket error for now.
Activity
arthurschreiber commentedon Jan 31, 2016
Hey @gshively11,
We've not implemented the "Cancel Timeout" correctly in Tedious. See https://msdn.microsoft.com/en-us/library/dd341108.aspx
This is definately something we should get fixed and support correctly.
arthurschreiber commentedon Jan 31, 2016
Here's another line from the specification (https://msdn.microsoft.com/en-us/library/dd356487.aspx):
So we're handling the request timeout correctly.
But on the next line, it says:
I also checked the code again to be sure. Although we have a cancelTimeout option, it's not honored anywhere. Adding the timeout should not be too hard.
gshively11 commentedon Feb 1, 2016
@arthurschreiber Thanks for clarifying, that makes sense now. I'll take a crack at a PR if I have time, but it may not be for a little while. I'd love to see this feature if you have the bandwidth! In the mean time, we can just rely on the socket error for now.
IanChokS commentedon Dec 18, 2019
Feature merged in #846