Java org.springframework.messaging.simp.stomp.ConnectionLostException:连接已关闭

Java org.springframework.messaging.simp.stomp.ConnectionLostException:连接已关闭,java,Java,我正在学习websocket编程,当我去连接websocket StompClient时,我遇到了一个异常org.springframework.messaging.simp.stomp.ConnectionLostException:Connection closed所以它无法正确连接有人能帮我吗? 这是我的密码: public class HelloClient { private final static WebSocketHttpHeaders headers = new WebSoc

我正在学习websocket编程,当我去连接websocket StompClient时,我遇到了一个异常
org.springframework.messaging.simp.stomp.ConnectionLostException:Connection closed
所以它无法正确连接有人能帮我吗? 这是我的密码:

public class HelloClient {

private final static WebSocketHttpHeaders headers = new WebSocketHttpHeaders();



public void connect() throws InterruptedException {

    Transport webSocketTransport = new WebSocketTransport(new StandardWebSocketClient());
    List<Transport> transports = Collections.singletonList(webSocketTransport);

    SockJsClient sockJsClient = new SockJsClient(transports);
    sockJsClient.setMessageCodec(new Jackson2SockJsMessageCodec());

    WebSocketStompClient stompClient = new WebSocketStompClient(sockJsClient);

    String auth = "t:t";
    String base64Credentials = Base64.getEncoder().encodeToString(auth.getBytes());
    headers.add("Authorization", "Basic " + base64Credentials);

    String url = "ws://188.75.73.196:7777/datxpapi/dtxws";
    stompClient.setInboundMessageSizeLimit(1000);
   ListenableFuture<StompSession> s= stompClient.connect(url, headers, new MySessionHandler()); 

   if(s.isDone()){
       System.out.println("s done working");
   }

   s.addCallback(new ListenableFutureCallback<StompSession>() {
       @Override
       public void onSuccess(StompSession  response) {
           System.out.println("Success");
           System.out.println(response);
       }

       @Override
       public void onFailure(Throwable t) {
         System.out.println("error");
       }
   });

}


public class MySessionHandler extends StompSessionHandlerAdapter {


    @Override
    public void afterConnected(StompSession session, 
                               StompHeaders connectedHeaders) {

            System.out.println("after connect");

    }

    @Override
    public void handleException(StompSession stompSession, StompCommand stompCommand, StompHeaders stompHeaders, byte[] bytes, Throwable throwable) {
        System.out.println("err0");
    }

    @Override
    public void handleTransportError(StompSession stompSession, Throwable throwable) {
        if (throwable instanceof ConnectionLostException) {
            System.out.println(throwable);            }
    }  
}

public static void main(String[] args) throws Exception {
    HelloClient helloClient = new HelloClient();
    helloClient.connect();
}

}

请在运行时添加完整堆栈traceno异常,此时print throwable此处显示此异常@Override public void HandletTransportError(StompSession StompSession,throwable throwable){if(throwable instanceof ConnectionLostException){System.out.println(throwable);}我的意思是logi中的完全异常添加完整trace@reallife74请阅读此内容。当print throwable在此显示此异常@Override public void HandletTransportError(StompSession StompSession,throwable throwable){if(ConnectionLostException的throwable instanceof)时,请在运行时添加完整堆栈traceno异常{System.out.println(throwable);}}我指的是logi中的完整异常添加完整的trace@reallife74请看这个。
at org.springframework.messaging.simp.stomp.DefaultStompSession.afterConnectionClosed(DefaultStompSession.java:459)
at org.springframework.web.socket.messaging.WebSocketStompClient$WebSocketTcpConnectionHandlerAdapter.afterConnectionClosed(WebSocketStompClient.java:353)
at org.springframework.web.socket.sockjs.client.AbstractClientSockJsSession.afterTransportClosed(AbstractClientSockJsSession.java:321)
at org.springframework.web.socket.sockjs.client.WebSocketTransport$ClientSockJsWebSocketHandler.afterConnectionClosed(WebSocketTransport.java:172)
at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.onClose(StandardWebSocketHandlerAdapter.java:143)
at org.eclipse.jetty.websocket.jsr356.endpoints.JsrEndpointEventDriver.onClose(JsrEndpointEventDriver.java:128)
at org.eclipse.jetty.websocket.jsr356.endpoints.AbstractJsrEventDriver.onClose(AbstractJsrEventDriver.java:80)
at org.eclipse.jetty.websocket.common.WebSocketSession.notifyClose(WebSocketSession.java:369)
at org.eclipse.jetty.websocket.common.WebSocketSession.onConnectionStateChange(WebSocketSession.java:401)
at org.eclipse.jetty.websocket.common.io.IOState.notifyStateListeners(IOState.java:185)
at org.eclipse.jetty.websocket.common.io.IOState.onAbnormalClose(IOState.java:220)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection$OnCloseLocalCallback.onLocalClose(AbstractWebSocketConnection.java:164)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection$OnCloseLocalCallback.writeSuccess(AbstractWebSocketConnection.java:154)
at org.eclipse.jetty.websocket.common.io.FrameFlusher.notifyCallbackSuccess(FrameFlusher.java:406)
at org.eclipse.jetty.websocket.common.io.FrameFlusher$Flusher.succeedEntries(FrameFlusher.java:241)
at org.eclipse.jetty.websocket.common.io.FrameFlusher$Flusher.succeeded(FrameFlusher.java:231)
at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:332)
at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:141)
at org.eclipse.jetty.websocket.common.io.FrameFlusher$Flusher.flush(FrameFlusher.java:152)
at org.eclipse.jetty.websocket.common.io.FrameFlusher$Flusher.process(FrameFlusher.java:216)
at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241)
at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:224)
at org.eclipse.jetty.websocket.common.io.FrameFlusher.enqueue(FrameFlusher.java:381)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.outgoingFrame(AbstractWebSocketConnection.java:581)
at org.eclipse.jetty.websocket.client.io.WebSocketClientConnection.outgoingFrame(WebSocketClientConnection.java:97)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.close(AbstractWebSocketConnection.java:271)
at org.eclipse.jetty.websocket.client.io.ConnectionManager.shutdownAllConnections(ConnectionManager.java:161)
at org.eclipse.jetty.websocket.client.io.ConnectionManager.doStop(ConnectionManager.java:192)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:161)
at org.eclipse.jetty.websocket.client.WebSocketClient.doStop(WebSocketClient.java:300)
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:161)
at org.eclipse.jetty.websocket.jsr356.ClientContainer.doStop(ClientContainer.java:213)
Caused by: org.springframework.messaging.simp.stomp.ConnectionLostException: Connection closed
at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
at org.eclipse.jetty.util.thread.ShutdownThread.run(ShutdownThread.java:138)