-
Notifications
You must be signed in to change notification settings - Fork 81
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
Unable to subscribe on topic using @stomp/stompjs #18
Comments
You definitely do not have a network connectivity issue, the broker has sent a reasonable response (the CONNECTED frame). I need some basic details - which broker and which browser are you using? Please create a minimal sample showing this problem to help in resolving this. |
@kum-deepak thanks for your response! Here is the sample . Broker is Spring's simple broker. Browser is Google Chrome 70.0.3538.67. I'm able to publish messages there, but subscription still doesn't work for me. Kindly let me know, if you'll see any problem there. |
There was a mixup in syntax, part of the syntax is v4 syntax while part is v5. I have converted totally to v5 syntax and it seems to work. Modified code: componentDidMount() {
console.log('Component did mount');
// The compat mode syntax is totally different, converting to v5 syntax
// Client is imported from '@stomp/stompjs'
this.client = new Client();
this.client.configure({
brokerURL: 'ws://localhost:8080/stomp',
onConnect: () => {
console.log('onConnect');
this.client.subscribe('/queue/now', message => {
console.log(message);
this.setState({serverTime: message.body});
});
this.client.subscribe('/topic/greetings', message => {
alert(message.body);
});
},
// Helps during debugging, remove in production
debug: (str) => {
console.log(new Date(), str);
}
});
this.client.activate();
} |
Please see akarasev/stomp-spring-react#1 Let me know if it works for you. Also, can I use your code as base for a sample? |
Works like a charm! Use my code whatever you need and thank you very much! |
Hello,
I'm not sure if this is an issue with
stomp-js
, but I'm unable to subscribe on any topic.Could you please help me to resolve the problem?
Thanks!
The text was updated successfully, but these errors were encountered: