Re: SocketException using C# driver on azure

Showing 1-7 of 7 messages
Re: SocketException using C# driver on azure craiggwilson 7/19/12 4:55 PM
I see that you are in a cursor.  How many documents are you pulling back at a time and how long does it take to iterate through them?

On Thursday, July 19, 2012 5:23:20 PM UTC-5, Keivan Beigi wrote:
We have a mongo replica set hosted on azure. every once in a while the connection to db fails and we get this error message.

is there a way to track this down and figure out what could be causing it? the error doesn't really say much beside the fact that connection failed.

System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at MongoDB.Bson.IO.BsonBuffer.LoadFrom(Stream stream, Int32 count)
   at MongoDB.Bson.IO.BsonBuffer.LoadFrom(Stream stream)
   at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument](BsonBinaryReaderSettings readerSettings, IBsonSerializationOptions serializationOptions)
   at MongoDB.Driver.MongoCursorEnumerator`1.GetReply(MongoConnection connection, MongoRequestMessage message)
   at MongoDB.Driver.MongoCursorEnumerator`1.GetFirst()
   at MongoDB.Driver.MongoCursorEnumerator`1.MoveNext()
Re: SocketException using C# driver on azure Keivan Beigi 7/19/12 7:53 PM
It doesn't seem to be a specific call, it just fails randomly on different calls. it seems to be an intermittent connection issue.
Re: SocketException using C# driver on azure sridhar 7/19/12 8:37 PM
Have you looked into this  http://blogs.msdn.com/b/avkashchauhan/archive/2011/11/12/windows-azure-load-balancer-timeout-details.aspx. According to this post, it should already be fixed. One way to test if this is your issue is to change the tcp keep alive and set it to something like 30 seconds. More information on setting the tcp keep alive can be found at  http://technet.microsoft.com/en-us/library/cc957548.aspx. Note since the keep alive is in milliseconds set it to 300,000. Do let us know if this helps.  
Re: [mongodb-user] Re: SocketException using C# driver on azure Keivan Beigi 7/19/12 8:44 PM
Should I use http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.settcpkeepalive.aspx
or http://technet.microsoft.com/en-us/library/cc957548.aspx?
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb
Re: [mongodb-user] Re: SocketException using C# driver on azure Keivan Beigi 7/22/12 8:45 AM
I tried updating the ttl on the db and app server machines, with non luck.

I also tried updating the driver's default values to these but still no help,

 MongoDefaults.MaxConnectionIdleTime = TimeSpan.FromHours(1);
 MongoDefaults.MaxConnectionLifeTime = TimeSpan.FromDays(1);
 MongoDefaults.SocketTimeout = TimeSpan.FromSeconds(30);
Re: [mongodb-user] Re: SocketException using C# driver on azure Keivan Beigi 7/23/12 11:10 AM
I think I've found the solution, 

MongoDefaults.MaxConnectionIdleTime = TimeSpan.FromMinutes(1); 

I think the issue is the driver trying to use connections that have been killed by azure for being idle. setting the idle time to 1 minutes fixes it, I'll try some other values to see how high i could take it without getting the socket exceptions.
Re: [mongodb-user] Re: SocketException using C# driver on azure sridhar 7/23/12 12:14 PM
Thanks for working through this and the post. This is definitely something I will include on our troubleshooting section for Azure.