C# WCF项目中的rabbitMQ返回错误,但它在同一台PC中的同一控制台项目中工作
我正试图发布来自wcf(4.5.2.net framework)项目的消息,如您所见:C# WCF项目中的rabbitMQ返回错误,但它在同一台PC中的同一控制台项目中工作,c#,rabbitmq,console-application,.net-framework-version,C#,Rabbitmq,Console Application,.net Framework Version,我正试图发布来自wcf(4.5.2.net framework)项目的消息,如您所见: public Int64 FindChargeByOrganization(string id) { var factory = new ConnectionFactory() { HostName = "localhost", UserName = "symfa", Password = "123qweQWE@&quo
public Int64 FindChargeByOrganization(string id)
{
var factory = new ConnectionFactory() { HostName = "localhost", UserName = "symfa", Password = "123qweQWE@" };
using (var connection = factory.CreateConnection())
using (var channel = connection.CreateModel())
{
channel.QueueDeclare(queue: "symfa_queue",
durable: false,
exclusive: false,
autoDelete: false,
arguments: null);
string message = "Hello World!";
var body = Encoding.UTF8.GetBytes(message);
channel.BasicPublish(exchange: "",
routingKey: "symfa_queue",
basicProperties: null,
body: body);
}
return 1;
}
当我调用URL时,会出现以下错误:
RabbitMQ.Client.Exceptions.BrokerUnreachableException: 'None of the specified endpoints were reachable'
IOException: connection.start was never received, likely due to a network timeout
This exception was originally thrown at this call stack:
RabbitMQ.Client.Framing.Impl.Connection.StartAndTune()
RabbitMQ.Client.Framing.Impl.Connection.Open(bool)
RabbitMQ.Client.Framing.Impl.Connection.Connection(RabbitMQ.Client.IConnectionFactory, bool, RabbitMQ.Client.Impl.IFrameHandler, string)
RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(RabbitMQ.Client.Impl.IFrameHandler)
RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(RabbitMQ.Client.IEndpointResolver)
RabbitMQ.Client.ConnectionFactory.CreateConnection(RabbitMQ.Client.IEndpointResolver, string)
但是,当我使用NetFramework4.5.2的控制台应用程序调用此代码时,它可以正常工作
那么你是在IIS Express下运行的(基于屏幕截图)?@mjwills是的……你试过在IIS而不是IIS Express中运行吗?@mjwills我检查过了。同样的错误