hi, I am having a issue with connect to CloudAMQP. That is the code and error
copy from the cloudamqp guideline.
void Start()
{
private static readonly string _url = "amqp://guest:guest@localhost/%2f";
// Create a ConnectionFactory and set the Uri to the CloudAMQP url
// the connectionfactory is stateless and can safetly be a static resource in your app
var factory = new ConnectionFactory
{
uri = new Uri(url)
};
// create a connection and open a channel, dispose them when done
using var connection = factory.CreateConnection();
using var channel = connection.CreateModel();
// ensure that the queue exists before we publish to it
var queueName = "queue1";
bool durable = false;
bool exclusive = false;
bool autoDelete = true;
channel.QueueDeclare(queueName, durable, exclusive, autoDelete, null);
// read message from input
var message = "";
// the data put on the queue must be a byte array
var data = Encoding.UTF8.GetBytes(message);
// publish to the "default exchange", with the queue name as the routing key
var exchangeName = "";
var routingKey = queueName;
channel.BasicPublish(exchangeName, routingKey, null, data);
}
the issues is
SocketException: An existing connection was forcibly closed by the remote host.
System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) (at <aa976c2104104b7ca9e1785715722c9d>:0)
System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) (at <aa976c2104104b7ca9e1785715722c9d>:0)
Rethrow as IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
does any one know how to slove it?