我正在使用Spring在线示例,该服务器托管在heroku上。
这是我的配置
food
和控制器
Apple
我正在尝试在this test online tool上可以想到的所有组合,但到目前为止根本没有运气。基本上,我尝试了@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/gs-guide-websocket").withSockJS();
}
}
,@Controller
public class GreetingController {
@MessageMapping("/hello")
@SendTo("/topic/greetings")
public TestResponse greeting(HelloMessage message) throws Exception {
Thread.sleep(1000); // simulated delay
return new TestResponse("Hello, " + HtmlUtils.htmlEscape(message.getName()) + "!");
}
}
,ws://[heroku_url]/hello
,ws://[heroku_url]/gs-guide-websocket
。他们都不工作!