Azure Function连接RabbitMQ遇System.Threading.Channels程序集缺失问题
Azure Function连接RabbitMQ时出现System.Threading.Channels程序集缺失问题
我有一个由HTTP POST触发的简单Azure Function,负责将请求负载转发至RabbitMQ,当前使用C#的RabbitMQ.Client库。但调用ConnectionFactory.CreateConnection()方法时,触发了端点无法访问错误,堆栈跟踪显示RabbitMQ客户端库找不到System.Threading.Channels程序集:
RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable [2023-04-14T09:23:45.676Z] ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Threading.Channels, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. [2023-04-14T09:23:45.676Z] [2023-04-14T09:23:45.676Z] File name: 'System.Threading.Channels, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' [2023-04-14T09:23:45.676Z] at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection..ctor(ConnectionFactory factory, String clientProvidedName) [2023-04-14T09:23:45.676Z] at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) [2023-04-14T09:23:45.676Z] --- End of inner exception stack trace --- [2023-04-14T09:23:45.676Z] at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
已尝试以下操作但问题仍未解决:
- 更换不同RabbitMQ服务器,其他服务可正常连接,但Azure Function依旧失败
- 通过NuGet安装System.Threading.Channels程序集
- 分别以独立运行、Docker Compose部署、Azure云环境连接公网RabbitMQ三种方式运行Azure Function
问题代码片段(已隐藏真实敏感信息):
var factory = new ConnectionFactory() { Uri = new Uri("amqp://user:pass@localhost:5672/vhost"), };
错误抛出位置:
using (var connection = factory.CreateConnection())
内容的提问来源于stack exchange,提问作者Daniel Eliasson
相关产品推荐
相关产品推荐

