1
我嘗試使用sockjs和stomp.js(http://jmesnil.net/stomp-websocket/doc/)爲vert.x stomp服務器編寫一個簡單的javascript stomp客戶端。但我堅持了在服務器端這個錯誤:使用vert.x stomp服務器的Javascript stomp客戶端
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)
據我所知,我的客戶使用GET請求到達服務器,但我不明白我該怎麼做才能解決這個問題。
這裏是我的服務器代碼:
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");
}
});
而我的客戶端代碼:
socket = new SockJS("http://localhost:1234");
stompClient = Stomp.over(socket);
stompClient.connect("guest", "guest", connectCallback, errorCallback);
有沒有人誰知道如何實現這一目標?
在此先感謝。