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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top