间歇性的MongoDB连接问题:尝试以其访问权限禁止的方式访问套接字 [英] Intermittent MongoDB Connection Issue: An attempt was made to access a socket in a way forbidden by its access permissions

查看:530
本文介绍了间歇性的MongoDB连接问题:尝试以其访问权限禁止的方式访问套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I get the following exception thrown occasionally when trying to write documents to my collection.

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

I am using MongoDB 3.0.7 hosted in mLabs. Our application is hosted in Azure (as a Web App) and I am using the C# 2.2.3 SDK.

MongoDB.Driver.MongoConnectionException:发生异常时 打开与服务器的连接. ---> System.Net.Sockets.SocketException:试图访问一个 套接字以其访问权限禁止的方式 191.235.xxx.xxx:54128位于System.Net.Sockets.Socket.Connect(IPAddress []地址,Int32端口)
在System.Net.Sockets.Socket.Connect(字符串主机,Int32端口)在 MongoDB.Driver.Core.Connections.TcpStreamFactory.Connect(Socket 套接字,EndPoint端点,CancellationToken cancelToken) MongoDB.Driver.Core.Connections.TcpStreamFactory.CreateStream(EndPoint endPoint,CancellationToken cancelToken) MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancelToken)-内部异常堆栈跟踪的结尾-在 MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancelToken) MongoDB.Driver.Core.Connections.BinaryConnection.Open(CancellationToken cancelToken) MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquiredConnection.Open(CancellationToken cancelToken) MongoDB.Driver.Core.Servers.ClusterableServer.GetChannel(CancellationToken cancelToken) MongoDB.Driver.Core.Bindings.ServerChannelSource.GetChannel(CancellationToken cancelToken) MongoDB.Driver.Core.Bindings.ChannelSourceHandle.GetChannel(CancellationToken cancelToken) MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.Execute(IWriteBinding 绑定,在 MongoDB.Driver.OperationExecutor.ExecuteWriteOperation [TResult](IWriteBinding 绑定,IWriteOperation'1操作,CancellationToken cancelToken) MongoDB.Driver.MongoCollectionImpl'1.ExecuteWriteOperation [TResult](IWriteOperation`1 操作,在以下位置使用CancellationToken cancelToken) MongoDB.Driver.MongoCollectionImpl'1.BulkWrite(IEnumerable'1个请求, BulkWriteOptions选项,在以下位置使用CancellationToken cancellingToken) MongoDB.Driver.MongoCollectionBase'1.InsertOne(TDocument文档, InsertOneOptions选项,CancellationToken cancelToken)

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)

推荐答案

如果达到沙箱限制,就会发生这种情况.我的旧答案中的更多详细信息 Azure Web应用程序中的间歇性崩溃

This happens if you hit the sandbox limits. More details in my old answer Intermittent crashes in Azure Web Application

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

To know about sandbox limits please refer to https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox

还遇到了 http ://www.freekpaans.nl/2015/08/starving-outgoing-connections-on-windows-azure-web-sites/很好地写在同一主题上

Also came across http://www.freekpaans.nl/2015/08/starving-outgoing-connections-on-windows-azure-web-sites/ which was nicely written on the same subject

编辑-2018年2月

Edit - February 2018

如果您现在正遇到此问题,请在 Azure门户网站中为您的应用程序转到诊断和解决刀片服务器,并检查 TCP连接平铺.它应该为您提供有关占用最大端口的站点的信息,并允许您监视整个实例的状态连接.

If you are running in to this issue now, go to Diagnose and Solve Blade for your App in the Azure portal and check the TCP Connections tile. It should give you information about the site consuming the maximum ports and allow you to monitor the state connections instance wide.

这篇关于间歇性的MongoDB连接问题:尝试以其访问权限禁止的方式访问套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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