连接之前Spring WebSocket中的STOMP失去连接

jas*_*uuu 5 java spring stomp websocket

我尝试通过STOMP与服务器连接,但是收到“丢失的连接”消息以及任何特定信息。

WebSocket配置:

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {
        registry.enableStompBrokerRelay("/topic", "/queve")
            .setClientLogin("quest")
            .setClientPasscode("quest");
        registry.setApplicationDestinationPrefixes("/app");
    }

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

}
Run Code Online (Sandbox Code Playgroud)

控制器:

@Controller
public class HelloController {


    @MessageMapping("/hello")
    public void greeting(HelloMessage message){
        System.out.println("Wiadomosc: " + message.getName());
    }

    @SubscribeMapping({"/helloSub"})
    public HelloMessage handleSubscription() {
        HelloMessage outgoing = new HelloMessage();
        System.out.println("SUB");
        outgoing.setName("Jas");
        return outgoing;
    }

}
Run Code Online (Sandbox Code Playgroud)

js脚本:

 var sock = new SockJS("http://localhost:8080/BuyMyTime/hello");
    var stomp = Stomp.over(sock);
    var payload = JSON.stringify({'name':'Jasiek'});
    stomp.connect('quest', 'quest', function(frame){
        //stomp.send("/hello", {}, payload);
    });
Run Code Online (Sandbox Code Playgroud)

当我发送获取http:// localhost:8080 / BuyMyTime / hello时,我收到:欢迎使用SockJS!所以套接字很好,但是当我尝试stomp.connect我收到:

Opening Web Socket... stomp.js:134:99
Web Socket Opened... stomp.js:134:99
>>> CONNECT
login:quest
passcode:quest
accept-version:1.1,1.0
heart-beat:10000,10000

"Whoops! Lost connection to http://localhost:8080/BuyMyTime/hello" stomp.js:134:99 
Run Code Online (Sandbox Code Playgroud)

我没有包含任何缺少的配置吗?如何获得有关此连接丢失的更多信息?请任何帮助。

更新(2016年8月28日)

我添加以下依赖项:

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.5.1</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.5.1</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.5.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

现在得到:

<<< ERROR
message:Broker not available.
content-length:0
"Whoops! Lost connection to http://localhost:8080/BuyMyTime/greeting"
Run Code Online (Sandbox Code Playgroud)