Tedious: ConnectionError: Failed to connect to <server name> in 15000ms #833

Created on 5 Dec 2018  ·  5Comments  ·  Source: tediousjs/tedious

Reopening this issue.
https://github.com/tediousjs/tedious/issues/833

I tried tedious-connection-pool and node-mssql module both are throwing same error.

Most helpful comment

Another update:
Based on the error, I forked and made a small change in the connection.js file to add the missing event in the fed auth state:
'routingChange' in state 'SentLogin7Withfedauth'
and then things seem to work fine and my service in the azure app service env is also able to connect to the server and get data. See for reference:
https://github.com/shani117/tedious/commit/0777bf6f5ad7f1701a355f8e706fd0ce5120eda4

I'm not yet ready to do a PR, but just wanted to get this out to see if I'm going down the right path or not.

Feedback appreciated.

All 5 comments

@aniltomar10 Could you send an isolated repo along with the stack trace?

I'm also facing this same exact issue when trying to connect to a SQL Azure DB using AAD auth. My service also connects to another SQL Azure DB that only uses SQL auth and that connection is working perfectly fine. Only the AAD auth one fails. When I did some log stream capture, I see this error is thrown every time before the connection attempt times out:

Error: No event 'routingChange' in state 'SentLogin7Withfedauth' at new Error (native) at Connection.dispatchEvent (D:\home\site\wwwroot\server.js:269168:26) at Parser.tokenStreamParser.on.token (D:\home\site\wwwroot\server.js:268857:12) at Zone.runTask (D:\home\site\wwwroot\server.js:259175:47) at Parser.ZoneTask.invoke (D:\home\site\wwwroot\server.js:259369:33) at emitOne (events.js:96:13) at Parser.emit (events.js:188:7) at Parser.parser.on.token (D:\home\site\wwwroot\server.js:274976:14) at Zone.runTask (D:\home\site\wwwroot\server.js:259175:47) at Parser.ZoneTask.invoke (D:\home\site\wwwroot\server.js:259369:33) at emitOne (events.js:96:13)

This is my exception stack trace that is logged to app insights:

ConnectionError: at ConnectionError (at ConnectionError (D:\home\site\wwwroot\server.js:34539:12) at ConnectionError (D:\home\site\wwwroot\server.js:34539:12): D:\home\site\wwwroot\server.js at ConnectionError (D:\home\site\wwwroot\server.js:34539:12): 34539) at Connection.connectTimeout (at Connection.connectTimeout (D:\home\site\wwwroot\server.js:269106:26) at Connection.connectTimeout (D:\home\site\wwwroot\server.js:269106:26): D:\home\site\wwwroot\server.js at Connection.connectTimeout (D:\home\site\wwwroot\server.js:269106:26): 269106) at Timeout.connectTimer.setTimeout (at Timeout.connectTimer.setTimeout (D:\home\site\wwwroot\server.js:269080:12) at Timeout.connectTimer.setTimeout (D:\home\site\wwwroot\server.js:269080:12): D:\home\site\wwwroot\server.js at Timeout.connectTimer.setTimeout (D:\home\site\wwwroot\server.js:269080:12): 269080) at ZoneDelegate.invokeTask (at ZoneDelegate.invokeTask (D:\home\site\wwwroot\server.js:259299:35) at ZoneDelegate.invokeTask (D:\home\site\wwwroot\server.js:259299:35): D:\home\site\wwwroot\server.js at ZoneDelegate.invokeTask (D:\home\site\wwwroot\server.js:259299:35): 259299) at Zone.runTask (at Zone.runTask (D:\home\site\wwwroot\server.js:259175:47) at Zone.runTask (D:\home\site\wwwroot\server.js:259175:47): D:\home\site\wwwroot\server.js at Zone.runTask (D:\home\site\wwwroot\server.js:259175:47): 259175) at Timeout.ZoneTask.invoke (at Timeout.ZoneTask.invoke (D:\home\site\wwwroot\server.js:259369:33) at Timeout.ZoneTask.invoke (D:\home\site\wwwroot\server.js:259369:33): D:\home\site\wwwroot\server.js at Timeout.ZoneTask.invoke (D:\home\site\wwwroot\server.js:259369:33): 259369) at Timeout.data.args.(anonymous function) [as _onTimeout] (at Timeout.data.args.(anonymous function) [as _onTimeout] (D:\home\site\wwwroot\server.js:260383:25) at Timeout.data.args.(anonymous function) [as _onTimeout] (D:\home\site\wwwroot\server.js:260383:25): D:\home\site\wwwroot\server.js at Timeout.data.args.(anonymous function) [as _onTimeout] (D:\home\site\wwwroot\server.js:260383:25): 260383) at ontimeout (at ontimeout (timers.js:365:14)at ontimeout (timers.js:365:14): timers.js at ontimeout (timers.js:365:14): 365) at tryOnTimeout (at tryOnTimeout (timers.js:237:5)at tryOnTimeout (timers.js:237:5): timers.js at tryOnTimeout (timers.js:237:5): 237) at Timer.listOnTimeout (at Timer.listOnTimeout (timers.js:207:5) at Timer.listOnTimeout (timers.js:207:5): timers.js at Timer.listOnTimeout (timers.js:207:5): 207)

I'm not sure if @aniltomar10 is also facing the same issue or not, but I thought it could be relevant in this case.

When I run the service locally on my development machine, everything works just fine. It starts failing when I deploy the service to azure app service.

Environment details:
NodeJS Version: 8.11.1
Tedious Version: 4.1.1

Let me know if I can add more details.

Thanks,
Shahnaz.

Another update:
Based on the error, I forked and made a small change in the connection.js file to add the missing event in the fed auth state:
'routingChange' in state 'SentLogin7Withfedauth'
and then things seem to work fine and my service in the azure app service env is also able to connect to the server and get data. See for reference:
https://github.com/shani117/tedious/commit/0777bf6f5ad7f1701a355f8e706fd0ce5120eda4

I'm not yet ready to do a PR, but just wanted to get this out to see if I'm going down the right path or not.

Feedback appreciated.

@shani117 Oh wow, yes, I think you've found the root cause of this issue! I'll see if I can open a PR with your changes tomorrow to get this fixed properly. Thank you so much! 🙇

:tada: This issue has been resolved in version 4.1.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

codethyme picture codethyme  ·  7Comments

anthonylau picture anthonylau  ·  8Comments

arthurschreiber picture arthurschreiber  ·  8Comments

diginfo picture diginfo  ·  6Comments

ghost picture ghost  ·  5Comments