Search code examples
javascriptstompvert.x

Javascript Stomp client with vert.x stomp server


I try to write a simple javascript stomp client for vert.x stomp server using sockjs and stomp.js ( http://jmesnil.net/stomp-websocket/doc/ ). But I'm stuck with this error on the server side :

java.lang.IllegalArgumentException: No enum constant io.vertx.ext.stomp.Frame.Command.GET /eventbus/info HTTP/
1.1
    at java.lang.Enum.valueOf(Enum.java:238)
    at io.vertx.ext.stomp.Frame$Command.valueOf(Frame.java:86)
    at io.vertx.ext.stomp.impl.FrameParser.handleLine(FrameParser.java:95)
    at io.vertx.core.parsetools.impl.RecordParserImpl.parseDelimited(RecordParserImpl.java:185)
    at io.vertx.core.parsetools.impl.RecordParserImpl.handleParsing(RecordParserImpl.java:159)
    at io.vertx.core.parsetools.impl.RecordParserImpl.handle(RecordParserImpl.java:218)
    at io.vertx.ext.stomp.impl.FrameParser.handle(FrameParser.java:201)
    at io.vertx.core.net.impl.NetSocketImpl.handleDataReceived(NetSocketImpl.java:313)
    at io.vertx.core.net.impl.VertxNetHandler.lambda$channelRead$30(VertxNetHandler.java:54)
    at io.vertx.core.impl.ContextImpl.lambda$wrapTask$18(ContextImpl.java:333)
    at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:225)
    at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:54)
    at io.vertx.core.net.impl.VertxNetHandler.channelRead(VertxNetHandler.java:31)
    at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:124)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
    at java.lang.Thread.run(Thread.java:745)

I understand that my client use a GET request to reach the server, but I can't understand how I can do to correct the problem.

Here is my server code :

   StompServer server = StompServer.create(vertx)
           .handler(StompServerHandler.create(vertx)
                   .destinationFactory((v, name) -> {
                       System.out.println(name);
                       return Destination.queue(vertx, "queue");
                   }) )
           .listen(1234, ar -> {
               if (ar.failed()) {
                   System.out.println("failed to start stomp");
               } else {
                   System.out.println("stomp ok");
               }
           });

And my client code :

socket = new SockJS("http://localhost:1234");
stompClient = Stomp.over(socket);
stompClient.connect("guest", "guest", connectCallback, errorCallback);

Is there someone who knows how to achieve this ?

Thanks in advance.


Solution

  • I found my answer here : https://github.com/vert-x3/vertx-stomp/issues/10

    And here : https://github.com/vert-x3/vertx-stomp/pull/11

    So I must wait the 3.3 release of vertx, which will support stompJS.