* BAEL-4648: How to debug Websockets * Formatted the code * Incorporated comments from Kevin
25 lines
994 B
Java
25 lines
994 B
Java
package com.baeldung.debugwebsockets;
|
|
|
|
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
|
|
import org.springframework.messaging.simp.stomp.StompSessionHandler;
|
|
import org.springframework.web.socket.client.WebSocketClient;
|
|
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
|
import org.springframework.web.socket.messaging.WebSocketStompClient;
|
|
|
|
import java.util.Scanner;
|
|
|
|
public class StompWebSocketClient {
|
|
|
|
private static final String URL = "ws://localhost:8080/stock-ticks/websocket";
|
|
|
|
public static void main(String[] args) {
|
|
WebSocketClient client = new StandardWebSocketClient();
|
|
WebSocketStompClient stompClient = new WebSocketStompClient(client);
|
|
stompClient.setMessageConverter(new MappingJackson2MessageConverter());
|
|
StompSessionHandler sessionHandler = new StompClientSessionHandler();
|
|
stompClient.connect(URL, sessionHandler);
|
|
|
|
new Scanner(System.in).nextLine();
|
|
}
|
|
}
|