间歇性 MongoDB 连接问题:尝试以访问权限禁止的方式访问套接字
Intermittent MongoDB Connection Issue: An attempt was made to access a socket in a way forbidden by its access permissions
我在尝试将文档写入我的集合时偶尔会抛出以下异常。
我正在使用托管在 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 月
如果您现在 运行 遇到此问题,请转到 诊断并解决 Blade 为您的应用在 Azure portal 并检查 TCP Connections 磁贴。它应该为您提供有关使用最大端口的站点的信息,并允许您监视实例范围内的状态连接。
我在尝试将文档写入我的集合时偶尔会抛出以下异常。
我正在使用托管在 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 月
如果您现在 运行 遇到此问题,请转到 诊断并解决 Blade 为您的应用在 Azure portal 并检查 TCP Connections 磁贴。它应该为您提供有关使用最大端口的站点的信息,并允许您监视实例范围内的状态连接。