【问题标题】:Apache ActiveMQ Artemis address already in useApache ActiveMQ Artemis 地址已在使用中
【发布时间】:2020-07-09 11:20:37
【问题描述】:

在 Windows 10 上,Apache ActiveMQ Artemis 2.11.0 无法启动,因为:

2020-03-28 23:03:04,322 INFO  [org.apache.activemq.artemis.core.server] AMQ221080: Deploying address ExpiryQueue supporting [ANYCAST] 
2020-03-28 23:03:04,322 INFO  [org.apache.activemq.artemis.core.server] AMQ221003: Deploying ANYCAST queue ExpiryQueue on address ExpiryQueue 
2020-03-28 23:03:06,418 ERROR [org.apache.activemq.artemis.core.server] AMQ224000: Failure in initialisation: java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method) [rt.jar:1.8.0_212]
        at sun.nio.ch.Net.bind(Net.java:433) [rt.jar:1.8.0_212]
        at sun.nio.ch.Net.bind(Net.java:425) [rt.jar:1.8.0_212]
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) [rt.jar:1.8.0_212]
        at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:130) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:563) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1332) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:488) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:473) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:984) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:259) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:366) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:495) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118) [artemis-commons-2.11.0.jar:2.11.0]
2020-03-28 23:03:06,423 INFO  [org.apache.activemq.artemis.core.server] AMQ221001: Apache ActiveMQ Artemis Message Broker version 2.11.0 [0.0.0.0, nodeID=61904c81-713a-11ea-ad5b-902b34592bce] 
2020-03-28 23:03:06,978 INFO  [org.apache.activemq.hawtio.branding.PluginContextListener] Initialized activemq-branding plugin

我见过这个post,和其他一些人一样。问题是我得到的错误是没有明确提及正在使用的端口,只有:

java.net.BindException: Address already in use: bind

我已经尝试了所有建议的解决方案,但徒劳无功。此外,没有conf 文件夹或activemq.xml 文件。

更新:通过前面的陈述,我的意思是我已经检查过了,Artemis 使用的端口都没有被其他一些服务/应用程序使用。

我能找到的只是代理的etc 文件夹中的broker.xml 文件。没有使用任何标准端口。还尝试禁用 ICS(Internet 连接共享) - 完全没有效果。

我错过了什么?

【问题讨论】:

    标签: activemq-artemis


    【解决方案1】:

    ActiveMQ 5.x 使用 conf/activemq.xml,但 ActiveMQ Artemis 使用 etc/broker.xml,所以您看到的内容是预期的。正如the answer you cited 所述,这里的最终问题是,已经有一个代理正在运行,或者正在运行的其他一些服务正在使用 ActiveMQ 想要绑定到的端口。

    ActiveMQ Artemis 默认绑定到少数端口。论文在etc/broker.xml 中定义。这是默认配置:

    <acceptors>
       <acceptor name="artemis">tcp://0.0.0.0:61616??anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300</acceptor>
       <acceptor name="amqp">tcp://0.0.0.0:5672?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=AMQP;useEpoll=true;amqpCredits=1000;amqpLowCredits=300</acceptor>
       <acceptor name="stomp">tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true</acceptor>
       <acceptor name="hornetq">tcp://0.0.0.0:5445?protocols=HORNETQ,STOMP;useEpoll=true</acceptor>
       <acceptor name="mqtt">tcp://0.0.0.0:1883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT;useEpoll=true</acceptor>
    </acceptors>
    

    因此,默认情况下,代理会绑定到这些端口:

    • 61616
    • 5672
    • 61613
    • 5445
    • 1883

    当您启动代理时,这些端口中的任何一个都可能已在使用中。您可能不需要您的代理来监听这些端口的所有,因此我建议您禁用除您绝对需要的所有端口之外的所有端口。如果这样可以解决您的问题,那就太好了,但如果没有,您可以使用消除过程来找到已经在使用的那个或来自other answer 的命令之一(例如netstatfuser 等)。确定有问题的端口后,您可以更改 broker.xml 以使用其他端口或停止已经在使用它的进程。

    如果确实没有使用任何端口,则意味着 JVM 网络堆栈的核心部分存在错误,因为这是异常的来源。我的直觉是没有这样的错误,所以我建议使用我之前提到的消除过程。尝试注释掉所有 acceptor 元素并启动代理。由于代理不会尝试绑定到任何端口,因此也不应该有例外。然后停止代理并添加acceptor 元素之一并重新启动代理。对每个acceptor 执行此操作,直到问题再次出现,此时您可以更改代理的配置以使用不同的端口。

    【讨论】:

    • 我应该更准确地更新问题。我已经尝试过,但没有使用任何端口。
    • 我发现一个人在其他论坛和我有同样的问题,同样的设置。也可能是一些 AV 或防火墙问题。你关于消除过程的想法很好。我会试试看。我知道 61616 没问题,因为我已经试过了。
    • 你有其他有同样问题的人的链接吗?
    • 它在 Udemy,JMS 课程的问答部分
    • 我试图找到问答部分here,但我找不到。我猜它是私人的。
    【解决方案2】:

    我只是要添加这个,以防有人偶然发现这篇文章并且上面的解决方案不起作用;

    我在配置第一个代理旁边的第二个代理时遇到了这个问题。我遇到了与 Java 抛出 java.net.BindException: Address already in use: bind 相同的问题。

    配置的接受器端口未使用,但问题是每个代理实例都有自己的管理控制台。因此,这个控制台也需要一个端口。在配置第二个代理时,ActiveMQ 设置了默认的控制台端口,与第一个代理的控制台端口相同。

    您还需要将bootstrap.xml 中的控制台端口更改为未使用的端口。

    希望这可以帮助你们中的一些人:)

    【讨论】:

      猜你喜欢
      • 2020-04-24
      • 2020-10-09
      • 1970-01-01
      • 1970-01-01
      • 2020-08-08
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多