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);
有没有人谁知道如何实现这一目标?
在此先感谢。