mongodb - 间歇性 MongoDB 连接问题 : An attempt was made to access a socket in a way forbidden by its access permissions

标签 mongodb azure-web-app-service mongodb-.net-driver

尝试将文档写入我的集合时,我偶尔会抛出以下异常。

我正在使用 mLabs 中托管的 MongoDB 3.0.7。我们的应用程序托管在 Azure 中(作为 Web 应用程序),我使用的是 C# 2.2.3 SDK。

MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 191.235.xxx.xxx:54128 at System.Net.Sockets.Socket.Connect(IPAddress[] addresses, Int32 port)
at System.Net.Sockets.Socket.Connect(String host, Int32 port) at MongoDB.Driver.Core.Connections.TcpStreamFactory.Connect(Socket socket, EndPoint endPoint, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.TcpStreamFactory.CreateStream(EndPoint endPoint, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken) --- End of inner exception stack trace --- at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.Open(CancellationToken cancellationToken) at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquiredConnection.Open(CancellationToken cancellationToken) at MongoDB.Driver.Core.Servers.ClusterableServer.GetChannel(CancellationToken cancellationToken) at MongoDB.Driver.Core.Bindings.ServerChannelSource.GetChannel(CancellationToken cancellationToken) at MongoDB.Driver.Core.Bindings.ChannelSourceHandle.GetChannel(CancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.Execute(IWriteBinding binding, CancellationToken cancellationToken) at MongoDB.Driver.OperationExecutor.ExecuteWriteOperation[TResult](IWriteBinding binding, IWriteOperation'1 operation, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl'1.ExecuteWriteOperation[TResult](IWriteOperation`1 operation, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl'1.BulkWrite(IEnumerable'1 requests, BulkWriteOptions options, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionBase'1.InsertOne(TDocument document, InsertOneOptions options, CancellationToken cancellationToken)

最佳答案

如果您达到沙盒限制,就会发生这种情况。我的旧答案中有更多详细信息 Intermittent crashes in Azure Web Application

要了解沙盒限制,请参阅 https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox

也遇到了http://www.freekpaans.nl/2015/08/starving-outgoing-connections-on-windows-azure-web-sites/就同​​一主题写得很好

编辑 - 2018 年 2 月

如果您现在遇到此问题,请在 Azure 门户 中为您的应用转到诊断和解决 Blade 并检查TCP 连接瓦。它应该为您提供有关使用最大端口的站点的信息,并允许您监视实例范围内的状态连接。

关于mongodb - 间歇性 MongoDB 连接问题 : An attempt was made to access a socket in a way forbidden by its access permissions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37292820/

相关文章:

mongodb - NoSQL 数据库 - 日志处理/聚合和汇总的良好候选者?

python - 在 Python 中从 MongoDB GridFS 加载 Spark 2.x DataFrame

c# - IAsyncCursor 如何与 mongodb c# 驱动程序一起用于迭代?

mongodb - Java访问MongoDb锁定/解锁并发

mongodb - 如何启用 mongodb cli pretty-print ? - db.col.find().pretty() 不工作

c# - 尽管在本地主机上工作,部署到 Azure 时 Azure Active Directory 始终重定向到 '~/.auth/login/done'

azure - 向 Google Play 证明 Azure 网站所有权

iis - 通过 Azure 云服务 RDP 访问现有的 Azure 网站

mongodb - 更新后 SafeModeResult 为空

c# - 如何使用 C# MongoDb 驱动程序更新深度嵌套数组中的字段 "type-safe"?