【发布时间】:2017-05-31 11:34:15
【问题描述】:
我们有一个 ASP.Net WebAPI 2.0 应用程序,可以将消息发布到我们的 RabbitMQ 服务器。在 99% 的情况下,一切都很好……但随机地,应用程序以 System.AccessViolationException 无故终止。
如何防止这种失败?会不会与我们最近升级到 3.6.6 C# 驱动有关(升级前它运行良好)?
我已经消除的东西:
- 每次发布都使用一个新的
IModel(我知道IModel不是线程 安全) - 每次通话都会拨打
CreateConnection(我 知道我可以重用连接,但我们目前没有)。连接是AutoClose = true; - Channel 用在 using 块中...所以每次都被释放
这里是它爆炸位置的示例堆栈跟踪:
异常详情
System.AccessViolationException
试图读或写保护 记忆。这通常表明其他内存已损坏。
在 System.Net.UnsafeNclNativeMethods.SafeNetHandlesXPOrLater.GetAddrInfoW(String nodename, String servicename, AddressInfo& 提示, SafeFreeAddrInfo& 处理) 在 System.Net.Dns.TryGetAddrInfo(字符串名称、AddressInfoHints 标志、IPHostEntry& 主机信息) 在 System.Net.Dns.InternalGetHostByName(字符串主机名,布尔值 includeIPv6) 在 System.Net.Dns.GetHostAddresses(字符串主机名或地址) 在 RabbitMQ.Client.TcpClientAdapter.BeginConnect(字符串主机,Int32 端口,AsyncCallback requestCallback,对象状态) 在 RabbitMQ.Client.Impl.SocketFrameHandler.Connect(ITcpClient 套接字,AmqpTcpEndpoint 端点,Int32 超时) 在 RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint 端点,Func`2 socketFactory,Int32 connectionTimeout,Int32 读超时,Int32 写超时) 在 RabbitMQ.Client.Framing.Impl.ProtocolBase.CreateFrameHandler(AmqpTcpEndpoint 端点,Func'2 socketFactory,Int32 connectionTimeout,Int32 读超时,Int32 写超时) 在 RabbitMQ.Client.ConnectionFactory.CreateConnection(IList'1 端点,字符串 clientProvidedName)
还有一个
System.Net.UnsafeNclNativeMethods+SafeNetHandlesXPOrLater.GetAddrInfoW(System.String, System.String,System.Net.AddressInfo ByRef, System.Net.SafeFreeAddrInfo ByRef) System.Net.Dns.TryGetAddrInfo(System.String, System.Net.AddressInfoHints, System.Net.IPHostEntry ByRef) System.Net.Dns.InternalGetHostByName(System.String, Boolean) System.Net.Dns.GetHostAddresses(System.String) RabbitMQ.Client.TcpClientAdapter.BeginConnect(System.String,Int32,System.AsyncCallback,System.Object) RabbitMQ.Client.Impl.SocketFrameHandler.Connect(RabbitMQ.Client.ITcpClient, RabbitMQ.Client.AmqpTcpEndpoint, Int32) RabbitMQ.Client.Impl.SocketFrameHandler..ctor(RabbitMQ.Client.AmqpTcpEndpoint, System.Func'2, Int32, Int32, Int32) RabbitMQ.Client.Framing.Impl.ProtocolBase.CreateFrameHandler(RabbitMQ.Client.AmqpTcpEndpoint, System.Func'2, Int32, Int32, Int32) RabbitMQ.Client.ConnectionFactory.CreateConnection(System.Collections.Generic.IList'1, System.String)
【问题讨论】:
标签: c# asp.net-web-api rabbitmq