我正在尝试在SSL (WSS)之上运行Netty Draft10的最新例子
我使用以下端口配置:
端口: 80: Apache非ssl
端口: 443: Apache ssl
端口: 8080: Tomcat
端口: 8877: Netty Web非SS
端口: 9977: Netty SSL
但是当我嵌入SSL处理程序代码时
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
//TODO - Tamir - Add support for Wss
// Get the SslHandler in the current pipeline.
// We added it in SecureChatPipelineFactory.
final SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
// Get notified when SSL handshake is done.
ChannelFuture handshakeFuture = sslHandler.handshake();
handshakeFuture.addListener(new Greeter(sslHandler));
}进入WebSocketServerHandler类时,我收到一条错误消息
java.lang.IllegalArgumentException: empty text
at org.jboss.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:95)
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:275)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:262)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:340)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:271)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:191)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
java.lang.IllegalArgumentException: invalid version format: ?_?_?__这是我的管道代码
SSLEngine engine =
SecureChatSslContextFactory.getServerContext().createSSLEngine();
engine.setUseClientMode(false);
pipeline.addLast("ssl", new SslHandler(engine));
// On top of the SSL handler, add the text line codec.
pipeline.addLast("decoder", new StringDecoder());
pipeline.addLast("encoder", new StringEncoder());
// and then business logic.
pipeline.addLast("handler", new WebSocketServerHandler());有什么想法吗?
干杯,
塔米尔
发布于 2011-11-13 10:08:06
我刚刚上传了一个使用SSL的web套接字的工作示例,我已经将其与master合并。
请参见拉取请求:https://github.com/netty/netty/pull/53。
新代码用src/main/java/org/jboss/netty/example/http/websocketx/sslserver编写
请阅读package-info.java中的设置说明。
如果对你有效,请让我知道。
发布于 2012-05-22 18:11:49
由于我自己遇到了这个问题,我想可能值得一提的是:
在某些情况下,initialLine参数HttpRequestDecoder的解析错误。如果您没有向URI添加路径,也就是说,您尝试ws://localhost:8080而没有向URL添加/websocket,则可能会发生这种情况。
return new DefaultHttpRequest(HttpVersion.valueOf(initialLine[2]),
HttpMethod.valueOf(initialLine[0]), initialLine[1]);HTTP version字段应该在initialLine2中,但它却出现在initialLine1中。
https://stackoverflow.com/questions/8025971
复制相似问题