SockJS - '/info' causing Http 404 while connecting server

徘徊边缘 提交于 2019-12-23 08:44:48

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/20605465/sockjs-info-causing-http-404-while-connecting-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!