MongoDB: Connection failed: Connection timed out (os error 110)
Hello,
I'm trying to understand if this is me or deploy. I have an app that connects to a remote MongoDB. I am able to connect fine locally and via other means using the same creds. In fact my app was able to connect fine yesterday. But currently I'm getting:
0 | Error: MongoError: "Connection failed: Connection timed out (os error 110)" at MongoClient.connect (https://deno.land/x/[email protected]/src/client.ts:26:19) at async Server.handleRequest (file:///src/mod.ts:13:9) at async Server.#respond (https://deno.land/[email protected]/http/server.ts:246:30)
-- | --
1 | Error: MongoError: "Connection failed: Connection timed out (os error 110)" at MongoClient.connect (https://deno.land/x/[email protected]/src/client.ts:26:19) at async Server.handleRequest (file:///src/mod.ts:13:9) at async Server.#respond (https://deno.land/[email protected]/http/server.ts:246:30)
2 | Error: MongoError: "Connection failed: Connection timed out (os error 110)" at MongoClient.connect (https://deno.land/x/[email protected]/src/client.ts:26:19) at async Server.handleRequest (file:///src/mod.ts:13:9) at async Server.#respond (https://deno.land/[email protected]/http/server.ts:246:30)
3 | Error: MongoError: "Connection failed: Connection timed out (os error 110)" at MongoClient.connect (https://deno.land/x/[email protected]/src/client.ts:26:19) at async Server.handleRequest (file:///src/mod.ts:13:9) at async Server.#respond (https://deno.land/[email protected]/http/server.ts:246:30)
...
In the logs: https://dash.deno.com/projects/kyan-jukebox-now-playing/logs
The app is just hanging (I guess due to the connection issue). Are you able to help?
In fact my app was able to connect fine yesterday.
It was able to connect on Deploy yesterday, but not today?
@lucacasonato phew, I'm not going mad! bump
No that was a question: you could connect yesterday, but you can not connect today?
Oh, sorry. Yes, I was able to connect yesterday. In fact I was able to connect earlier today but no longer.
Ok, I will investigate. One thing I saw while reviewing your code is that you create a new connection to MongoDB for each request. This is very expensive - you should create one connection upfront, and then re-use that.
Are you able to connect to this MongoDB instance locally right now?
Yep. This is the app running locally under deno run. You can see the 200 and data.
This looks to be a Deno Deploy issue. I'll get back to you once I know more!
Thanks for your help Luca
It worked once this morning, and then froze again. Logs say:
0 | 2021-11-12 08:45:40 | Error closing connection: TypeError: Deno.close is not a function
1 | 2021-11-12 08:45:40 | Error closing connection: TypeError: Deno.close is not a function
2 | 2021-11-12 08:45:40 | Error closing connection: TypeError: Deno.close is not a function
3 | 2021-11-12 08:43:04 | Error closing connection: TypeError: Deno.close is not a function
4 | 2021-11-12 08:43:04 | Error closing connection: TypeError: Deno.close is not a function
5 | 2021-11-12 08:43:04 | Error closing connection: TypeError: Deno.close is not a function
Not sure why there are so many errors logged. I only made a single request to the app? Is my app wrong?
You can see the mongoDB connections went up dramatically too with just a single request?!
It worked once this morning, and then froze again. Logs say:
0 | 2021-11-12 08:45:40 | Error closing connection: TypeError: Deno.close is not a function 1 | 2021-11-12 08:45:40 | Error closing connection: TypeError: Deno.close is not a function 2 | 2021-11-12 08:45:40 | Error closing connection: TypeError: Deno.close is not a function 3 | 2021-11-12 08:43:04 | Error closing connection: TypeError: Deno.close is not a function 4 | 2021-11-12 08:43:04 | Error closing connection: TypeError: Deno.close is not a function 5 | 2021-11-12 08:43:04 | Error closing connection: TypeError: Deno.close is not a functionNot sure why there are so many errors logged. I only made a single request to the app? Is my app wrong?
I have opened a PR to deno_mongo to fix this issue: https://github.com/denodrivers/deno_mongo/pull/293