Это моя конфигурация:
Код: Выделить всё
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/chat");
registry.addEndpoint("/chat").withSockJS();
}
}
Код: Выделить всё
@Controller
public class WebSocketController {
@MessageMapping("/chat")
@SendTo("/topic/messages")
public OutputMessage send(Message message) throws Exception {
return new OutputMessage(message.getFrom(), message.getText(), Instant.now());
}
}
Код: Выделить всё
@Builder
@Getter
public class Message {
private final String from;
private final String text;
}
@Builder
@Getter
public class OutputMessage {
private final String from;
private final String text;
private final Instant date;
}
Код: Выделить всё
2021-12-31 14:22:39.442 INFO 1952 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0]
Я выполнил следующие конечные точки:
Код: Выделить всё
ws://localhost/app/chat
ws://localhost:8080/app/chat
ws://localhost/chat
ws://localhost:8080/chat
Я использую бета-версию Postman Websockets для выполнения запросов.Я что-то пропустил в конфигурации или неправильно использую postaman?
Подробнее здесь: https://stackoverflow.com/questions/705 ... ng-postman
Мобильная версия