0

我已经在套接字上配置了日志。我想在 socket.io(Java)上读取日志对象(在套接字上配置)。当我执行日志程序时,socket-io 收到请求但抛出以下异常。

java.lang.IllegalArgumentException: empty text at org.jboss.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:103) at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:68) at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:81) at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:198) at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:107) at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:470) at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:443) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274) at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261) at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:351) at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:282) at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:202) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) java.lang.IllegalArgumentException: invalid version format: TIMESTAMP[

我从网上获取代码。这是一个代码链接:https ://github.com/ibdknox/socket.io-netty/tree/master/src/main/java/com/ibdknox/socket_io_netty 服务器类链接。 https://gist.github.com/965499

4

1 回答 1

0

WebSocketServerHandler中,您似乎想要处理 HTTP 请求或 WebSocketFrame

public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    Object msg = e.getMessage();
    if (msg instanceof HttpRequest) {
        handleHttpRequest(ctx, (HttpRequest) msg);
    } else if (msg instanceof WebSocketFrame) {
        handleWebSocketFrame(ctx, (WebSocketFrame) msg);
    }
}

但是在WebSocketServerPipelineFactory中,您使用的是 HttpRequestDecoder。

public ChannelPipeline getPipeline() throws Exception {
    // Create a default pipeline implementation.
    ChannelPipeline pipeline = pipeline();
    pipeline.addLast("decoder", new HttpRequestDecoder());

如果您使用的是 HttpRequestDecoder,您至少需要有一个有效的 HTTP 请求行加上一个 Content-Length 标头。

于 2012-07-25T17:52:01.357 回答