Spring 'Sec-WebSocket-Accept' value incorrect












0















When connecting to a WebSocket from my frontend (using Stomp for Dart):



client = await connect(uri);


The client sends this key in the header:



Sec-WebSocket-Key: ydWCNEacB1ZqiHCH1Ip+vo4mhOw=


And receives a key back from the Spring WebSocket:



Sec-WebSocket-Accept: KVqExHty0Y5/fze11/EAhg==


This causes the client to throw:




WebSocket connection to 'ws://user:pass@localhost:8080/ws'
failed: Error during WebSocket handshake: Incorrect
'Sec-WebSocket-Accept' header value




I don't know how to calculate the correct response. But either way the client doesn't accept it for some reason.



How do I approach this problem? What could be causing the problem and how might I solve it?



Thanks





Edit: added websocket config:



@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {


@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.setApplicationDestinationPrefixes("/app").enableSimpleBroker("/topic");
}

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws").setAllowedOrigins("*");
registry.addEndpoint("/ws").setAllowedOrigins("*").withSockJS();
}
}


Also



@Configuration
public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {

@Override
protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) {
messages.anyMessage().authenticated();
}
}




Edit: I found a wiki that describes how to calculate 'Sec-WebSocket-Key'. Following the guide below, it does look like the key is incorrect. This doesn't seem likely though or many more would be having issues.
https://en.wikipedia.org/wiki/WebSocket










share|improve this question

























  • First of all show your code and then we will see together what is the problem

    – Abdelghani Roussi
    Nov 14 '18 at 13:43











  • That's a bit of a problem. It's a large project and I have no idea what's causing the issue. As for the frontend, the connect(...) part above should be the only relevant part.

    – GreyScreenOfMeh
    Nov 14 '18 at 13:44













  • show us the config of your webSocket server

    – Abdelghani Roussi
    Nov 14 '18 at 13:46











  • Edited message to add config.

    – GreyScreenOfMeh
    Nov 14 '18 at 13:49
















0















When connecting to a WebSocket from my frontend (using Stomp for Dart):



client = await connect(uri);


The client sends this key in the header:



Sec-WebSocket-Key: ydWCNEacB1ZqiHCH1Ip+vo4mhOw=


And receives a key back from the Spring WebSocket:



Sec-WebSocket-Accept: KVqExHty0Y5/fze11/EAhg==


This causes the client to throw:




WebSocket connection to 'ws://user:pass@localhost:8080/ws'
failed: Error during WebSocket handshake: Incorrect
'Sec-WebSocket-Accept' header value




I don't know how to calculate the correct response. But either way the client doesn't accept it for some reason.



How do I approach this problem? What could be causing the problem and how might I solve it?



Thanks





Edit: added websocket config:



@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {


@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.setApplicationDestinationPrefixes("/app").enableSimpleBroker("/topic");
}

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws").setAllowedOrigins("*");
registry.addEndpoint("/ws").setAllowedOrigins("*").withSockJS();
}
}


Also



@Configuration
public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {

@Override
protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) {
messages.anyMessage().authenticated();
}
}




Edit: I found a wiki that describes how to calculate 'Sec-WebSocket-Key'. Following the guide below, it does look like the key is incorrect. This doesn't seem likely though or many more would be having issues.
https://en.wikipedia.org/wiki/WebSocket










share|improve this question

























  • First of all show your code and then we will see together what is the problem

    – Abdelghani Roussi
    Nov 14 '18 at 13:43











  • That's a bit of a problem. It's a large project and I have no idea what's causing the issue. As for the frontend, the connect(...) part above should be the only relevant part.

    – GreyScreenOfMeh
    Nov 14 '18 at 13:44













  • show us the config of your webSocket server

    – Abdelghani Roussi
    Nov 14 '18 at 13:46











  • Edited message to add config.

    – GreyScreenOfMeh
    Nov 14 '18 at 13:49














0












0








0


1






When connecting to a WebSocket from my frontend (using Stomp for Dart):



client = await connect(uri);


The client sends this key in the header:



Sec-WebSocket-Key: ydWCNEacB1ZqiHCH1Ip+vo4mhOw=


And receives a key back from the Spring WebSocket:



Sec-WebSocket-Accept: KVqExHty0Y5/fze11/EAhg==


This causes the client to throw:




WebSocket connection to 'ws://user:pass@localhost:8080/ws'
failed: Error during WebSocket handshake: Incorrect
'Sec-WebSocket-Accept' header value




I don't know how to calculate the correct response. But either way the client doesn't accept it for some reason.



How do I approach this problem? What could be causing the problem and how might I solve it?



Thanks





Edit: added websocket config:



@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {


@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.setApplicationDestinationPrefixes("/app").enableSimpleBroker("/topic");
}

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws").setAllowedOrigins("*");
registry.addEndpoint("/ws").setAllowedOrigins("*").withSockJS();
}
}


Also



@Configuration
public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {

@Override
protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) {
messages.anyMessage().authenticated();
}
}




Edit: I found a wiki that describes how to calculate 'Sec-WebSocket-Key'. Following the guide below, it does look like the key is incorrect. This doesn't seem likely though or many more would be having issues.
https://en.wikipedia.org/wiki/WebSocket










share|improve this question
















When connecting to a WebSocket from my frontend (using Stomp for Dart):



client = await connect(uri);


The client sends this key in the header:



Sec-WebSocket-Key: ydWCNEacB1ZqiHCH1Ip+vo4mhOw=


And receives a key back from the Spring WebSocket:



Sec-WebSocket-Accept: KVqExHty0Y5/fze11/EAhg==


This causes the client to throw:




WebSocket connection to 'ws://user:pass@localhost:8080/ws'
failed: Error during WebSocket handshake: Incorrect
'Sec-WebSocket-Accept' header value




I don't know how to calculate the correct response. But either way the client doesn't accept it for some reason.



How do I approach this problem? What could be causing the problem and how might I solve it?



Thanks





Edit: added websocket config:



@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {


@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.setApplicationDestinationPrefixes("/app").enableSimpleBroker("/topic");
}

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws").setAllowedOrigins("*");
registry.addEndpoint("/ws").setAllowedOrigins("*").withSockJS();
}
}


Also



@Configuration
public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {

@Override
protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) {
messages.anyMessage().authenticated();
}
}




Edit: I found a wiki that describes how to calculate 'Sec-WebSocket-Key'. Following the guide below, it does look like the key is incorrect. This doesn't seem likely though or many more would be having issues.
https://en.wikipedia.org/wiki/WebSocket







spring spring-boot websocket dart angular-dart






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 15:32







GreyScreenOfMeh

















asked Nov 14 '18 at 13:38









GreyScreenOfMehGreyScreenOfMeh

638




638













  • First of all show your code and then we will see together what is the problem

    – Abdelghani Roussi
    Nov 14 '18 at 13:43











  • That's a bit of a problem. It's a large project and I have no idea what's causing the issue. As for the frontend, the connect(...) part above should be the only relevant part.

    – GreyScreenOfMeh
    Nov 14 '18 at 13:44













  • show us the config of your webSocket server

    – Abdelghani Roussi
    Nov 14 '18 at 13:46











  • Edited message to add config.

    – GreyScreenOfMeh
    Nov 14 '18 at 13:49



















  • First of all show your code and then we will see together what is the problem

    – Abdelghani Roussi
    Nov 14 '18 at 13:43











  • That's a bit of a problem. It's a large project and I have no idea what's causing the issue. As for the frontend, the connect(...) part above should be the only relevant part.

    – GreyScreenOfMeh
    Nov 14 '18 at 13:44













  • show us the config of your webSocket server

    – Abdelghani Roussi
    Nov 14 '18 at 13:46











  • Edited message to add config.

    – GreyScreenOfMeh
    Nov 14 '18 at 13:49

















First of all show your code and then we will see together what is the problem

– Abdelghani Roussi
Nov 14 '18 at 13:43





First of all show your code and then we will see together what is the problem

– Abdelghani Roussi
Nov 14 '18 at 13:43













That's a bit of a problem. It's a large project and I have no idea what's causing the issue. As for the frontend, the connect(...) part above should be the only relevant part.

– GreyScreenOfMeh
Nov 14 '18 at 13:44







That's a bit of a problem. It's a large project and I have no idea what's causing the issue. As for the frontend, the connect(...) part above should be the only relevant part.

– GreyScreenOfMeh
Nov 14 '18 at 13:44















show us the config of your webSocket server

– Abdelghani Roussi
Nov 14 '18 at 13:46





show us the config of your webSocket server

– Abdelghani Roussi
Nov 14 '18 at 13:46













Edited message to add config.

– GreyScreenOfMeh
Nov 14 '18 at 13:49





Edited message to add config.

– GreyScreenOfMeh
Nov 14 '18 at 13:49












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301576%2fspring-sec-websocket-accept-value-incorrect%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301576%2fspring-sec-websocket-accept-value-incorrect%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues