Closed ShantaramTupe closed 6 years ago
solved this by
function connect( temp ) {
alert(temp);
//var socket = new SockJS("/websock");
//var socket = new SockJS("/websock"+temp);
var socket = new SockJS(context_path+"/websock"+temp);
//context_path == "/SupportCenter"
stompClient = Stomp.over(socket);
stompClient.connect({}, function( frame ){
console.log( "Connected :- "+frame );
stompClient.subscribe("/topic/notifications", function( notifications ) {
alert( notifications );
});
getNotifications();//************Changed Here
}, function( error ) {
alert( error );
});
}
Would like to look at how settings in your project, could you make your repository available? I am using a project with the same versions, please
@arthurlima96 Project is quite big, not able to make it available as repository, what issue you are facing ?
I'm facing configuration issues like: pom.xml (from websocket without Spring Boot) and where to add the WebSocketConfig configuration class
It´s my error https://gist.github.com/anonymous/09e526be8c9acb469f2302b2051db4ea
` public class ServletSpringMVC extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class<?>[] {AppWebConfiguration.class};
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class<?>[]{WebSocketConfig.class};
}
@Override
protected String[] getServletMappings() {
return new String[] {"/"};
}
@Override
protected void customizeRegistration(Dynamic registration) {
registration.setAsyncSupported(true);
}
} `
` @Configuration @EnableWebSocketMessageBroker
@ComponentScan(basePackageClasses={SockController.class}) public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
System.out.println("WEB 1");
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
System.out.println("WEB 2");
registry.addEndpoint("/chat").setAllowedOrigins("*").withSockJS();
}
} `
You've java.lang.NoSuchMethodError
coming from WebSocketMessageBrokerConfigurationSupport
which is trying to call CustomScopeConfigurer.addScope
. That method was added in 4.1.1 so it looks like you have a pre-4.1.1 spring-beans
on your classpath. Use mvn dependency:tree
to analyze what's pulling it in.
Keep in mind 4.3.x is the only currently supported branch for the 4th generation, and the only one that continues to get fixes (including security fixes). So you need to be on the latest 4.3.x.
I solved the spring-bean version, thank you very much @rstoyanchev .
Invalid SockJS path '/topic/public' - required to have 3 path segments same error !!!
I am implementing Notification System. And want to initialize Socket connection when user Logged In, and show him his notifications, and also if some event happens.
My Code snippet as follows.
websocket.js :
WebSocketConfig.java :
WebSocketController.java :
Some code Hom.jsp :
Why Firefox Console giving XML Parsing Error: no root element found Location: while in Network tab status code is 200 OK. ? What is the cause for this, any suggestions?
Versions I'm using Spring-MVC - 4.1.6 STOMP - 1.7.1 SockJS-client - 1.1.4
Console TAB
Network TAB