deploy_feedback icon indicating copy to clipboard operation
deploy_feedback copied to clipboard

MongoDB: Connection failed: Connection timed out (os error 110)

Open whomwah opened this issue 4 years ago • 11 comments

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?

whomwah avatar Nov 11 '21 11:11 whomwah

In fact my app was able to connect fine yesterday.

It was able to connect on Deploy yesterday, but not today?

lucacasonato avatar Nov 11 '21 11:11 lucacasonato

@lucacasonato phew, I'm not going mad! bump

whomwah avatar Nov 11 '21 11:11 whomwah

No that was a question: you could connect yesterday, but you can not connect today?

lucacasonato avatar Nov 11 '21 11:11 lucacasonato

Oh, sorry. Yes, I was able to connect yesterday. In fact I was able to connect earlier today but no longer.

whomwah avatar Nov 11 '21 11:11 whomwah

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?

lucacasonato avatar Nov 11 '21 11:11 lucacasonato

Yep. This is the app running locally under deno run. You can see the 200 and data.

Screenshot 2021-11-11 at 11 25 19

whomwah avatar Nov 11 '21 11:11 whomwah

This looks to be a Deno Deploy issue. I'll get back to you once I know more!

lucacasonato avatar Nov 11 '21 11:11 lucacasonato

Thanks for your help Luca

whomwah avatar Nov 11 '21 11:11 whomwah

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?

whomwah avatar Nov 12 '21 08:11 whomwah

You can see the mongoDB connections went up dramatically too with just a single request?!

Screenshot 2021-11-12 at 08 49 15

whomwah avatar Nov 12 '21 08:11 whomwah

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?

I have opened a PR to deno_mongo to fix this issue: https://github.com/denodrivers/deno_mongo/pull/293

lucacasonato avatar Nov 12 '21 09:11 lucacasonato