Skip to content

Sockjs XHR Fallback on already existing WebSocketServerSockJsSession [SPR-14867] #19433

Closed
@spring-projects-issues

Description

@spring-projects-issues

Michael Nahler opened SPR-14867 and commented

When a web socket client with an existing WebSocketServerSockJsSession falls back to XHR transport then I get the following error:

java.lang.ClassCastException: org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession cannot be cast to org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession
	at org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService.handleTransportRequest(TransportHandlingSockJsService.java:313)
	at org.springframework.web.socket.sockjs.support.AbstractSockJsService.handleRequest(AbstractSockJsService.java:433)
	at org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.handleRequest(SockJsHttpRequestHandler.java:132)
	... 96 common frames omitted
Caused by: java.lang.ClassCastException: org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession cannot be cast to org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession
	at org.springframework.web.socket.sockjs.transport.handler.AbstractHttpSendingTransportHandler.handleRequest(AbstractHttpSendingTransportHandler.java:57)
	at org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService.handleTransportRequest(TransportHandlingSockJsService.java:306)
	... 98 common frames omitted

As client I use springs WebSocketStompClient with sockJs and RestTemplateXhrTransport as fallback option:

List<Transport> transports = new ArrayList<>(2);
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
transports.add(new RestTemplateXhrTransport());
SockJsClient sockJsTransport = new SockJsClient(transports);
WebSocketStompClient stompClient = new WebSocketStompClient(sockJsTransport);

Affects: 4.2.6

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions