0

我们最近从传统的 spring 项目迁移到 Spring boot 1.3.1。我们现有的客户使用 Tyrus 1.12 作为 websocket 客户端。

升级后发现客户端不再连接并抛出AuthenticationException。奇怪的是,他们能够在服务器重新启动后第一次连接,并在抛出 AuthenticationException 后不久。进一步挖掘,我发现 Tyrus 最初收到 401 并随后传递凭据。服务器日志通过首先分配 ROLE_ANONYMOUS 和正确的角色 ROLE_GUEST 来指示相同的行为。

似乎在协商之后,服务器关闭连接并断开连接。

在使用带有 Tyrus 的 spring stomp websocket 客户端时,我观察到了相同的行为。

  ClientManager container = ClientManager.createClient();
        container.getProperties().put("org.glassfish.tyrus.client.sharedContainer", true);
        container.getProperties().put(ClientProperties.CREDENTIALS, new Credentials("guest", "guest"));
        StandardWebSocketClient webSocketClient = new StandardWebSocketClient(container);
        final CountDownLatch messageLatch = new CountDownLatch(10);
        WebSocketStompClient stompClient = new WebSocketStompClient(webSocketClient);

当凭据在标头中发送时,相同的服务器设置工作正常。

stompClient.connect(url,  getHandshakeHeaders("guest", "guest"), handler);

将不起作用,因为凭据不在标题中

ListenableFuture<StompSession>session = stompClient.connect(url, handler, "localhost", "8080");

我不明白为什么它以一种方式而不是另一种方式工作。

升级到 spring-boot 后,我​​们的软件不再向后兼容,并且必须要求我们所有的外部客户端在收到 401 之前在 header 中注入授权。

有人可以帮忙吗?

我之前的 stacktrace 帖子

4

0 回答 0