vert-x3 / vertx-stomp

STOMP client/server implementation
Apache License 2.0
31 stars 28 forks source link

stomp path must be a regex instead of string #38

Open am-kram opened 6 years ago

am-kram commented 6 years ago

https://github.com/vert-x3/vertx-stomp/blob/master/src/main/java/io/vertx/ext/stomp/impl/StompServerImpl.java#L217

due to this - can't use stomp with sockjs as sock js adds: /stomp/<rand id 1>/<rand id 2>/websocket to the websocket url.

Additionally, there is no degradation of websocket to xhr supported.

cescoffier commented 6 years ago

You can use the sockJS bridge to support degradation.

About the regex, that's a good idea. Fancy a PR?

am-kram commented 6 years ago

I will make a pr - i tested the regex functionality - it works but for some reason i am not receiving any messages when i send via a stomp client (even for a simplepath).

I see it receives the connection - but after that, the receivedHandler is never invoked. Is there a working example of stomp over sockjs websocket that you could point me to?

    Router router = Router.router(vertx);

    StompServer server = StompServer.create(vertx, new StompServerOptions()
      .setPort(-1) // Disable the TCP port, optional
      .setWebsocketBridge(true) // Enable the web socket support
      .setWebsocketPath("/stomp")) // Configure the web socket path, /stomp by default
      .handler(StompServerHandler.create(vertx).receivedFrameHandler(sf ->{
          System.out.println(sf.frame().getBodyAsString());
          logger.info(sf.frame().getBodyAsString());
      }));

    HttpServer http = vertx.createHttpServer(
            new HttpServerOptions().setWebsocketSubProtocols("v10.stomp, v11.stomp")
    )
      .websocketHandler(server.webSocketHandler())
      .requestHandler(router::accept)
      .listen(8080);

I tried this as well - not seeing any messages

    StompServer server = StompServer.create(vertx, new StompServerOptions()
      .setPort(-1) // Disable the TCP port, optional
      .setWebsocketBridge(true) // Enable the web socket support
      .setWebsocketPath("/stomp")) // Configure the web socket path, /stomp by default
      .handler(StompServerHandler.create(vertx).stompHandler(sf ->{
          System.out.println(sf.frame().getBodyAsString());
          logger.info(sf.frame().getBodyAsString());
      }));

I also commented https://github.com/vert-x3/vertx-stomp/issues/34#issuecomment-387945546 Basically, stomp over sockjs or just stomp over websocket seems hard to get it to work. I am trying to port a spring boot based stomp impl to vertx.