Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STOMP Connection Error #200

Closed
sincang opened this issue Feb 20, 2018 · 9 comments
Closed

STOMP Connection Error #200

sincang opened this issue Feb 20, 2018 · 9 comments
Labels
Milestone

Comments

@sincang
Copy link

sincang commented Feb 20, 2018

When connecting directly to a Spring Boot WebSocket service, I am not getting an error. When thought the gateway, I am not able to connect. When I check the headers during handshake, gateway is not specifying the sub protocols. Please see the images for reference.

Directly to the websocket service
img_8122

Through gateway
img_8123

@spencergibb
Copy link
Member

What version are you using?

@sincang
Copy link
Author

sincang commented Feb 20, 2018

I was using M5 then tried M6. It is same error.

@spencergibb
Copy link
Member

Please try with snapshots?

@sincang
Copy link
Author

sincang commented Feb 20, 2018

Same error with 2.0.0.BUILD-SNAPSHOT.

@sincang
Copy link
Author

sincang commented Feb 21, 2018

I may have found the issue. Will provide detail shortly.

@sincang
Copy link
Author

sincang commented Feb 21, 2018

As shown below, the request header for Sec-WebSocket-Protocol is "v10.stomp, v11.stomp". When establishing the handshake, my Spring Websocket only return "V10.stomp". What happened was org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService is comparing 2 different strings when trying to if the protocol is supported.

Fix is in WebsocketRoutingFilter.
Change at line 63 to below

List<String> protocols = headers.get(SEC_WEBSOCKET_PROTOCOL);
to
List<String> protocols = headers.get(SEC_WEBSOCKET_PROTOCOL).stream() .flatMap(p -> Arrays.stream(p.split(","))) .map(String::trim) .collect(Collectors.toList());

The value in the header just needed to be broken down.

screen shot 2018-02-20 at 10 04 32 pm

@spencergibb spencergibb added this to the 2.0.0.M7 milestone Feb 21, 2018
@spencergibb
Copy link
Member

Thanks, @sincang for the detailed investigation. Made for an easy fix and test.

@sincang
Copy link
Author

sincang commented Feb 21, 2018

Thanks also for the free software.

@kentoj
Copy link

kentoj commented Feb 28, 2018

Lol I wasted about 5 hours on this today. Thanks for having this here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants