3
我有一個Java vertx服務器和一個JavaScript客戶端。我想下兩次,但vertx響應創建事件總線:連接上收到的錯誤:ACCESS_DENIEDVertx事件總線access_denied
Javascript代碼:
var eventBus = new vertx.EventBus("http://localhost:8989/eventbus");
eventBus.onopen = function() {
console.log("Event bus connected !");
console.log(eventBus);
eventBus.registerHandler("http://localhost:8989/eventbus/news-feed", function (message) {
console.log("registred" + message.body());
});
Java代碼:
SockJSHandler bridge = SockJSHandler.create(vertx).bridge(new BridgeOptions());
router.route("/eventbus/*").handler(bridge);
router.route().handler(StaticHandler.create());// otherwise serve static pages
HttpServer httpServer = vertx.createHttpServer();
httpServer.requestHandler(router::accept);
httpServer.listen(Servers.SERVER_PORT);
vertx.setPeriodic(1000, event -> {
vertx.eventBus().publish("news-feed", "{\"c\":\"df\"}");
你有一個想法?
問候