Apache.NMS.NMSConnectionException: 'Error connecting to activemqhost:61616.'

Apache.NMS.NMSConnectionException: 'Error connecting to activemqhost:61616.'

我在 .NET Framework 4.7.2 中有控制台项目,它安装了 Apache.NMSApache.NMS.ActiveMQ 包。我从 official documentation 复制并粘贴示例代码,当我 运行 它时,它遇到错误 Apache.NMS.NMSConnectionException: 'Error connecting to activemqhost:61616.' SocketException

这是我的代码:

class Program
{
    public static void Main(string[] args)
    {
        // Example connection strings:
        //    activemq:tcp://activemqhost:61616
        //    stomp:tcp://activemqhost:61613
        //    ems:tcp://tibcohost:7222
        //    msmq://localhost

        Uri connecturi = new Uri("activemq:tcp://activemqhost:61616");

        Console.WriteLine("About to connect to " + connecturi);

        // NOTE: ensure the nmsprovider-activemq.config file exists in the executable folder.
        IConnectionFactory factory = new NMSConnectionFactory(connecturi);

        using (IConnection connection = factory.CreateConnection())
        {

        }
    }
}

以下来自我的 activemq.xml

   <transportConnectors>
        <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
        <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    </transportConnectors>

在我使用这个连接字符串后解决了Uri connecturi = new Uri("tcp://localhost:61616");