Javascript Stomp 客户端与 vert.x Stomp 服务器
Javascript Stomp client with vert.x stomp server
我尝试使用 sockjs 和 stomp.js ( http://jmesnil.net/stomp-websocket/doc/ ) 为 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(VertxNetHandler.java:54)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask(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.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);
有人知道如何实现吗?
提前致谢。
我在这里找到了答案:
https://github.com/vert-x3/vertx-stomp/issues/10
这里:
https://github.com/vert-x3/vertx-stomp/pull/11
所以我必须等待 vertx 的 3.3 版本,它将支持 stompJS。
我尝试使用 sockjs 和 stomp.js ( http://jmesnil.net/stomp-websocket/doc/ ) 为 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(VertxNetHandler.java:54)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask(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.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);
有人知道如何实现吗?
提前致谢。
我在这里找到了答案: https://github.com/vert-x3/vertx-stomp/issues/10
这里: https://github.com/vert-x3/vertx-stomp/pull/11
所以我必须等待 vertx 的 3.3 版本,它将支持 stompJS。