vert-x3 / vertx-stomp

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

Cannot configure Auth with WebSocket server #48

Open vasicvuk opened 5 years ago

vasicvuk commented 5 years ago

I have added HttpServer with WebSocket handler for STOMPSever like this:

  Vertx vertx = Vertx.vertx();

        StompServerHandler handler = StompServerHandler.create(vertx).authProvider(new AuthenticationProvider());
        StompServer server = StompServer.create(vertx, 
                    new StompServerOptions()
                            .setSecured(true)
                            .setWebsocketBridge(true)
                           // .setPort(-1)
                            .setWebsocketPath("/broker/stomp")
                )
                .handler(handler)
                .listen(61613, "0.0.0.0");

        HttpServer http = vertx.createHttpServer(
                new HttpServerOptions().setWebsocketSubProtocols("v10.stomp, v11.stomp, v12.stomp")
        )
                .websocketHandler(server.webSocketHandler())

                .listen(61614);

But i get exception:

SEVERE: Unhandled exception
java.lang.NullPointerException
    at io.vertx.ext.stomp.impl.DefaultStompHandler.onAuthenticationRequest(DefaultStompHandler.java:437)
    at io.vertx.ext.stomp.DefaultConnectHandler.authenticate(DefaultConnectHandler.java:86)
    at io.vertx.ext.stomp.DefaultConnectHandler.handle(DefaultConnectHandler.java:70)
    at io.vertx.ext.stomp.DefaultConnectHandler.handle(DefaultConnectHandler.java:41)
    at io.vertx.ext.stomp.impl.DefaultStompHandler.handleConnect(DefaultStompHandler.java:379)
    at io.vertx.ext.stomp.impl.DefaultStompHandler.handle(DefaultStompHandler.java:235)
    at io.vertx.ext.stomp.impl.DefaultStompHandler.handle(DefaultStompHandler.java:66)
    at io.vertx.ext.stomp.impl.StompServerImpl.lambda$null$13(StompServerImpl.java:237)
    at io.vertx.ext.stomp.impl.FrameParser.handleLine(FrameParser.java:164)
    at io.vertx.core.parsetools.impl.RecordParserImpl.parseDelimited(RecordParserImpl.java:202)
    at io.vertx.core.parsetools.impl.RecordParserImpl.handleParsing(RecordParserImpl.java:176)
    at io.vertx.core.parsetools.impl.RecordParserImpl.handle(RecordParserImpl.java:235)
    at io.vertx.ext.stomp.impl.FrameParser.handle(FrameParser.java:221)
    at io.vertx.ext.stomp.impl.FrameParser.handle(FrameParser.java:35)
    at io.vertx.core.http.impl.WebSocketImplBase.handleFrame(WebSocketImplBase.java:268)
    at io.vertx.core.http.impl.Http1xServerConnection.handleOther(Http1xServerConnection.java:499)
    at io.vertx.core.http.impl.Http1xServerConnection.processMessage(Http1xServerConnection.java:460)
    at io.vertx.core.http.impl.Http1xServerConnection.handleMessage(Http1xServerConnection.java:144)
    at io.vertx.core.http.impl.HttpServerImpl$ServerHandlerWithWebSockets.handleMessage(HttpServerImpl.java:676)
    at io.vertx.core.http.impl.HttpServerImpl$ServerHandlerWithWebSockets.handleMessage(HttpServerImpl.java:619)
    at io.vertx.core.net.impl.VertxHandler.lambda$channelRead$1(VertxHandler.java:146)
    at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:337)
    at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:195)
    at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:144)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:141)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:748)

when i try to login from STOMP over web socket