gpt4 book ai didi

java - 启用客户端共享容器后,Tyrus 客户端无法在服务器重新启动时重新连接

转载 作者:太空宇宙 更新时间:2023-11-04 13:35:22 25 4
gpt4 key购买 nike

这是场景:

  1. Websocket 服务器已启动
  2. Tyrus 客户端共享容器已启用
  3. Tyrus 客户端连接到服务器(一切正常)
  4. Websocket 服务器重新启动
  5. 即使服务器启动后,Tyrus 客户端也无法连接到服务器并引发以下异常:

javax.websocket.DeploymentException:连接失败

  • 如果客户端应用程序重新启动,它可以再次连接到服务器
  • 注意:如果Tyrus client shared container,则不会发生此问题已禁用。

    堆栈跟踪:

    javax.websocket.DeploymentException: Connection failed.
    at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket._connect(GrizzlyClientSocket.java:428) ~[tyrus-container-grizzly-client-1.11.jar:?]
    at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket.access$000(GrizzlyClientSocket.java:103) ~[tyrus-container-grizzly-client-1.11.jar:?]
    at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket$1.call(GrizzlyClientSocket.java:235) ~[tyrus-container-grizzly-client-1.11.jar:?]
    at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket$1.call(GrizzlyClientSocket.java:231) ~[tyrus-container-grizzly-client-1.11.jar:?]
    at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket.connect(GrizzlyClientSocket.java:249) ~[tyrus-container-grizzly-client-1.11.jar:?]
    at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientContainer.openClientSocket(GrizzlyClientContainer.java:95) ~[tyrus-container-grizzly-client-1.11.jar:?]
    at org.glassfish.tyrus.client.ClientManager$3$1.run(ClientManager.java:663) ~[tyrus-client-1.11.jar:?]
    at org.glassfish.tyrus.client.ClientManager$3.run(ClientManager.java:712) ~[tyrus-client-1.11.jar:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_31]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_31]
    at org.glassfish.tyrus.client.ClientManager$SameThreadExecutorService.execute(ClientManager.java:866) ~[tyrus-client-1.11.jar:?]
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112) ~[?:1.8.0_31]
    at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:511) ~[tyrus-client-1.11.jar:?]
    at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:373) ~[tyrus-client-1.11.jar:?]
    ...
    Caused by: java.lang.NullPointerException
    at org.glassfish.grizzly.nio.RoundRobinConnectionDistributor$SharedIterator.next(RoundRobinConnectionDistributor.java:146) ~[grizzly-framework-2.3.15-gfa.jar:2.3.15-gfa]
    at org.glassfish.grizzly.nio.RoundRobinConnectionDistributor.registerChannelAsync(RoundRobinConnectionDistributor.java:101) ~[grizzly-framework-2.3.15-gfa.jar:2.3.15-gfa]
    at org.glassfish.grizzly.nio.transport.TCPNIOConnectorHandler.connectAsync(TCPNIOConnectorHandler.java:177) ~[grizzly-framework-2.3.15-gfa.jar:2.3.15-gfa]
    at org.glassfish.grizzly.AbstractSocketConnectorHandler.connect(AbstractSocketConnectorHandler.java:91) ~[grizzly-framework-2.3.15-gfa.jar:2.3.15-gfa]
    at org.glassfish.grizzly.AbstractSocketConnectorHandler.connect(AbstractSocketConnectorHandler.java:79) ~[grizzly-framework-2.3.15-gfa.jar:2.3.15-gfa]
    at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket._connect(GrizzlyClientSocket.java:386) ~[tyrus-container-grizzly-client-1.11.jar:?]
    ... 41 more

    NPE 来自 grizzly 项目文件 RoundRobinConnectionDistributor.java:146 中的行 if (runners.length == 1) {

    private final class SharedIterator implements Iterator {
    private final AtomicInteger counter = new AtomicInteger();

    @Override
    public SelectorRunner next() {
    final SelectorRunner[] runners = getTransportSelectorRunners();
    if (runners.length == 1) {
    return runners[0];
    }

    return runners[(counter.getAndIncrement() & 0x7fffffff) % runners.length];
    }

    @Override
    public SelectorRunner nextService() {
    return next();
    }
    }

    看起来 runnersnull

    最佳答案

    对于任何感兴趣的人,此问题已在 Tyrus 1.12 中修复。通过这个pull request 。感谢@pavel 和他的团队采取的行动:)

    关于java - 启用客户端共享容器后,Tyrus 客户端无法在服务器重新启动时重新连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31757377/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com