-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Closed
Description
I have a simple test websocket server that echoes back messages from clients. In spring-boot 1.2.1, it works fine, but in 1.2.2, it now fails to work. It looks like the clients do not connect successfully.
This is the server warning message when a client attempts to connect:
WARN 5422 --- [nio-8080-exec-1] org.springframework.web.util.WebUtils : Failed to parse Origin header value [null]
@ComponentScan
@Controller
@EnableAutoConfiguration
@EnableWebSocket
public class EchoWebSocketServer implements WebSocketConfigurer {
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(handler(), "/test");
}
@Bean
public WebSocketHandler handler() {
return new ExceptionWebSocketHandlerDecorator(new Handler() );
}
public static void main(String[] args) throws Exception {
SpringApplication.run(EchoWebSocketServer.class, args);
}
}
public class Handler implements WebSocketHandler{
@Override
public void handleMessage(WebSocketSession session,
WebSocketMessage<?> encodedMessage) throws Exception {
if (encodedMessage instanceof org.springframework.web.socket.TextMessage) {
org.springframework.web.socket.TextMessage castedTextMessage = (org.springframework.web.socket.TextMessage) encodedMessage;
String message = castedTextMessage.getPayload();
session.sendMessage(new org.springframework.web.socket.TextMessage(message));
System.out.println(message);
}
}
@Override
public void afterConnectionClosed(WebSocketSession arg0, CloseStatus arg1)
throws Exception {
}
@Override
public void afterConnectionEstablished(WebSocketSession arg0)
throws Exception {
org.springframework.web.socket.TextMessage message =
new org.springframework.web.socket.TextMessage("connected");
}
@Override
public void handleTransportError(WebSocketSession arg0, Throwable arg1)
throws Exception {
}
@Override
public boolean supportsPartialMessages() {
return false;
}
}
Metadata
Metadata
Assignees
Labels
No labels