I've mainly followed below posts for implementing push notifications using SockJS,
Push Notifications for Java Webapp, SockJS Client, SockJS Java Server.
My sockJS client is:
var sock = new SockJS("http://localhost:8080/pusher");
sock.onmessage = function(event) {
console.log("message: " + event.data);
alert('received message echoed from server: ' + event.data);
};
*Server is listening same port 8080. But while running I got error 404:
GET http://localhost:8080/pusher/info 404 (Not Found)
This post on StackOverflow doesn't solve my problem. Please check what I'm missing. Do I need to register client or publish server to enable the push notifications. Thanks in advance!
You must follow this pattern: https://github.com/sockjs/sockjs-node/blob/master/examples/express-3.x/server.js
Pay close attention to the fact that calling app.listen
will NOT work, you must call server.listen
. So the .listen
call must be on the http instance, not on the express instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With