Google Groups

Re: Full duplex communication?


Rahul Somasunderam Apr 5, 2012 2:03 PM
Posted in group: asynchttpclient
Looks like I got lucky. I upgraded my tomcat to 7.0.27. And AHC to 1.7.2.

I'm now getting this exception:

java.lang.IllegalStateException: Invalid upgrade protocol, status should be 101 but was 501
at com.ning.http.client.websocket.WebSocketUpgradeHandler.onStatusReceived(WebSocketUpgradeHandler.java:67)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider$WebSocketProtocol.handle(NettyAsyncHttpProvider.java:2307)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.messageReceived(NettyAsyncHttpProvider.java:1117)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndFireMessageReceived(ReplayingDecoder.java:522)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:501)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:438)
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:343)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:274)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:194)
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:680)
Caught: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Invalid upgrade protocol, status should be 101 but was 501
java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Invalid upgrade protocol, status should be 101 but was 501
at com.ning.http.client.providers.netty.NettyResponseFuture.abort(NettyResponseFuture.java:297)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.abort(NettyAsyncHttpProvider.java:1315)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.exceptionCaught(NettyAsyncHttpProvider.java:1531)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:117)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:777)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.exceptionCaught(ReplayingDecoder.java:456)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:117)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:553)
at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:426)
at org.jboss.netty.channel.AbstractChannelSink.exceptionCaught(AbstractChannelSink.java:47)
at org.jboss.netty.channel.DefaultChannelPipeline.notifyHandlerException(DefaultChannelPipeline.java:645)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:777)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndFireMessageReceived(ReplayingDecoder.java:522)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:501)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:438)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:553)
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:343)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:274)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:194)
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
Caused by: java.lang.IllegalStateException: Invalid upgrade protocol, status should be 101 but was 501
at com.ning.http.client.websocket.WebSocketUpgradeHandler.onStatusReceived(WebSocketUpgradeHandler.java:67)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider$WebSocketProtocol.handle(NettyAsyncHttpProvider.java:2307)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.messageReceived(NettyAsyncHttpProvider.java:1117)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndFireMessageReceived(ReplayingDecoder.java:522)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:501)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:438)
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:343)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:274)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:194)
730 [New I/O client worker #1-1] WARN com.ning.http.client.providers.netty.NettyAsyncHttpProvider - onError [id: 0x50c7833c, /127.0.0.1:58254 => localhost/127.0.0.1:8080] EXCEPTION: java.lang.IllegalStateException: Invalid upgrade protocol, status should be 101 but was 501
733 [New I/O client worker #1-1] ERROR com.ning.http.client.providers.netty.NettyAsyncHttpProvider - onError
java.lang.IllegalStateException: WebSocket is null
at com.ning.http.client.websocket.WebSocketUpgradeHandler.onCompleted(WebSocketUpgradeHandler.java:85)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider$WebSocketProtocol.onError(NettyAsyncHttpProvider.java:2370)
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.exceptionCaught(NettyAsyncHttpProvider.java:1538)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:117)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:777)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.exceptionCaught(ReplayingDecoder.java:456)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:117)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:553)
at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:426)
at org.jboss.netty.channel.AbstractChannelSink.exceptionCaught(AbstractChannelSink.java:47)
at org.jboss.netty.channel.DefaultChannelPipeline.notifyHandlerException(DefaultChannelPipeline.java:645)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:777)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndFireMessageReceived(ReplayingDecoder.java:522)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:501)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:438)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:553)
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:343)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:274)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:194)
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$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)

R,
rahul


On Apr 4, 2012, at 2:47 PM, Rahul Somasunderam wrote:

7.0.26 still doesn't support WebSockets.

Thanks!

R,
rahul

On Wednesday, April 4, 2012 1:09:07 PM UTC-7, jfarcand wrote:
Salut,

On 12-04-04 4:00 PM, Rahul Somasunderam wrote:
Hi Jeanfrançois,

I'm using your AsyncHttpClient library with a custom handler that implements AsyncHandler<String>. Would I have to rewrite it to use Websockets?
I believe the server component will automcatically support WebSockets since it uses Atmosphere.
With AHC you will need to switch handler...I'm working on an Atmosphere Java Client for the upcoming 1.0.0 release that will hides that and will negotiate with the Atmosphere server which transport is the best/optimal....but first I need to release Atmosphere 0.9 before I start working on that :-) So long answer to say that you will need to do some AHC work ... Tomcat 7 doesn't yet support Websocket so you may have to be force to use HTTP (or 7.0.26 might be, need to check).

A+

-- Jeanfrancois


R,
rahul

On Apr 4, 2012, at 12:39 PM, Jeanfrancois Arcand wrote:

Salut,

On 12-04-04 3:27 PM, Rahul Somasunderam wrote:
Hi,

I'm having a server running atmosphere inside of grails on tomcat 7. My client is not a browser, but a java based client built with AHC.

I've been successful in implementing this model:


Server starts up.
Client starts up.
<-- Client connects to server.
--> Server receives message somehow that needs to be sent to client.
Server sends message to client -->
Client receives message
Client creates response
<-- Client sends response over a new connection.

This works beautifully. I've now got a new scenario to address:

Server starts up.
Client starts up.
<-- Client connects to server.
--> Server receives message somehow that needs to be sent to client.
Server sends message to client -->
Client receives message
Client creates response
<-- Client sends response over same connection.
<-- Server responds to the source of the message synchronously

Changes are in bold.

Has anyone implemented something like this? Is it possible?

yes, that will works with WebSocket for sure (open a single connection, duplex call on it). It can work as well using HTTP + keep-alive (but you have to make sure your HTTP client/Javascript re-use the same connection for the client second request) => for sure that will works with long-polling. For http-streaming I don't think you can re-use the same connection.

Which client are you using?

A+

-- Jeanfrancois





TIA.

R,
rahul
--
You received this message because you are subscribed to the Google Groups "asynchttpclient" group.
To post to this group, send email to asyncht...@googlegroups.com.
To unsubscribe from this group, send email to asynchttpclie...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/asynchttpclient?hl=en.

--
You received this message because you are subscribed to the Google Groups "asynchttpclient" group.
To post to this group, send email to asyncht...@googlegroups.com.
To unsubscribe from this group, send email to asynchttpclie...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/asynchttpclient?hl=en.

--
You received this message because you are subscribed to the Google Groups "asynchttpclient" group.
To post to this group, send email to asyncht...@googlegroups.com.
To unsubscribe from this group, send email to asynchttpclie...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/asynchttpclient?hl=en.

--
You received this message because you are subscribed to the Google Groups "asynchttpclient" group.
To view this discussion on the web visit https://groups.google.com/d/msg/asynchttpclient/-/Knj9jvtOld8J.
To post to this group, send email to asyncht...@googlegroups.com.
To unsubscribe from this group, send email to asynchttpclie...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/asynchttpclient?hl=en.