尝试在Azure上将数据发送到mongoDB时出现SocketException [英] SocketException when trying to send data to mongoDB on Azure

查看:74
本文介绍了尝试在Azure上将数据发送到mongoDB时出现SocketException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Azure平台上的Windows Server 2012 R2的VM中托管了一个mongodb副本集,我的问题是,当我尝试使用C#驱动程序从外部客户端插入数据甚至从GUI查询它们时,客户端(mongoVUE,robomongo ...)我经常收到以下永久锁定程序的异常(即使尝试使用Server.reconnect()也无法解决).

I have a mongodb replica set hosted in a VM wjth Windows Server 2012 R2 on the Azure platform, my problem is that when I'm trying to insert data from an external client using the C# driver or even consulting them from a GUI client (mongoVUE, robomongo ...) I often get the following exception which permanently locks the program (even trying a Server.reconnect() does not resolve).

No such host is known
Type: System.Net.Sockets.SocketException

Stack:    at System.Net.Dns.GetAddrInfo(String name)
   at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
   at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
   at MongoDB.Driver.MongoServerAddress.ToIPEndPoint(AddressFamily addressFamily)
   at MongoDB.Driver.MongoServerInstance.GetIPEndPoint()

我尝试设置:

MongoDefaults.SocketTimeout = TimeSpan.FromMinutes(5);
MongoDefaults.ConnectTimeout = TimeSpan.FromMinutes(5);
MongoDefaults.MaxConnectionIdleTime = TimeSpan.FromMinutes(5);

在连接字符串中放入服务器的硬编码公共IP地址,并从不同位置对其进行测试,但是服务器上似乎有某些东西阻止了连接.

putting an hardcoded public IP address of the server in the connection string and testing it from different locations but it seems that something on the server blocking connections.

有人知道我该如何解决吗?

Has anyone any idea how I can fix it?

推荐答案

我解决了!问题是,我使用未正确配置的单个副本集启动了mongodb,在启动mongod时删除了--replset选项,这些都可以正常工作.

I solved!The problem was that I started mongodb with a single replica set that's not configured correctly, removing the option --replset when starting mongod all works correctly.

这篇关于尝试在Azure上将数据发送到mongoDB时出现SocketException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆