无效的握手响应异常

时间:2013-03-13 14:54:51

标签: java-ee websocket ioexception

我正在使用我们的tomcat服务器进行压力测试,该服务器通过websocket技术与客户端进行通信。因此,当我在客户端尝试超过150个并发用户时,我收到此异常,我不知道服务器想要说什么。

java.util.concurrent.ExecutionException: java.io.IOException: Invalid handshake response
    at com.ning.http.client.providers.netty.NettyResponseFuture.abort(NettyResponseFuture.java:297)
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.abort(NettyAsyncHttpProvider.java:1376)
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.access$800(NettyAsyncHttpProvider.java:137)
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider$WebSocketProtocol.handle(NettyAsyncHttpProvider.java:2400)
    at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.messageReceived(NettyAsyncHttpProvider.java:1178)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:792)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndFireMessageReceived(ReplayingDecoder.java:600)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:584)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:445)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
    at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:94)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:372)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:246)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:38)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.IOException: Invalid handshake response
    ... 23 more

如果你能提供帮助,请告诉我。

由于

2 个答案:

答案 0 :(得分:0)

您必须遵循在浏览器客户端上遵循的相同规则

在您的客户端,您可能已添加以下代码

$ atmosphere.subscribe(请求);

你也必须在你的java客户端上做同样的事情,因为你的请求没有订阅气氛,所以气氛并不是你的请求。在java方面,首先你要做大气连接,然后你必须解雇你的请求......

答案 1 :(得分:0)

最可能的原因是,如果不使用“websocket”,您可能没有客户端URL:

“ws://”+ HOST +“:”+ PORT +“/ websocket”

如果在与服务器通信时错过/ websocket客户端代码,则会出现此异常