connection lost in azure websites

153 views
Skip to first unread message

José F. Romaniello

unread,
Sep 25, 2012, 8:52:10 AM9/25/12
to node-mong...@googlegroups.com
Hello I am experiencing a problem with mongodb native when running an application on windows azure websites. 


This code creates a connection to mongodb, authenticate it, and then it starts a web server that does a query to the db on each request using the same connection instance.

This works fine for about 10 minutes but after that it seems that azure recycle the application or something alike, and then the query fails. The error message and the stack trace are in the page of the reproduction i made.

So, my question is... even if azure is closing the socket of the connection, shouldn't auto_reconnect reconnect it ? Anyone experienced a problem like this?

Thank you very much.

Christian Kvalheim

unread,
Sep 25, 2012, 8:57:03 AM9/25/12
to node-mong...@googlegroups.com
if there is no activity on a connection mongodb will close it after 10 minutes.


set the keep alive settings on the driver and see if it helps. Unfortunately I don't have any experience with Azure myself so if does not help it might be a Azure thing.

Auto reconnect means it will reconnect on the next operation not that the error is magically handled. The reason is simple. If an insert or update is in flight the driver cannot just automatically replay the insert/update as it might have gone through before the failure.

José F. Romaniello

unread,
Sep 25, 2012, 9:15:24 AM9/25/12
to node-mong...@googlegroups.com
Hi Christian and thank you very much for your prompt response. I have few questions, I will write in-line

2012/9/25 Christian Kvalheim <chri...@gmail.com>

if there is no activity on a connection mongodb will close it after 10 minutes.

Why we cant reproduce this when running it locally or in a VM in the cloud?
 


set the keep alive settings on the driver and see if it helps. Unfortunately I don't have any experience with Azure myself so if does not help it might be a Azure thing.

Auto reconnect means it will reconnect on the next operation not that the error is magically handled. The reason is simple. If an insert or update is in flight the driver cannot just automatically replay the insert/update as it might have gone through before the failure.


You mention insert/update, but is this still valid for queries (collection.find(...).toArray())?

and the last question is what is the syntax for seting the keepAlive?, I cant find any example. I saw that the Server constructor has a socketOptions I imagine something like this:
new mongodb.Server(host, port, {keepAlive: true} )

 thanks again!

christkv

unread,
Sep 25, 2012, 9:58:54 AM9/25/12
to node-mong...@googlegroups.com
A good place to start is the docs


new mongodb.Server(host, port, {socketOptions : {keepAlive: true}} )

When it comes to why it behaves differently on azure I don't know. Different environment causes different problems.

José F. Romaniello

unread,
Sep 25, 2012, 10:42:21 AM9/25/12
to node-mong...@googlegroups.com
thanks Chris, setting a keepAlive definitely solved my problem, 

2012/9/25 christkv <chri...@gmail.com>
Reply all
Reply to author
Forward
0 new messages