Re: WebSocket clinet with Grizzly

  • From: Ryan Lubke <ryan.lubke@...>
  • To: users@...
  • Subject: Re: WebSocket clinet with Grizzly
  • Date: Thu, 02 May 2013 14:55:52 -0700

May 2, 2013 2:30 PM

I'm not sure if this is the right mailing list for the question. I subscribed for a few weeks ago but didn't see too much traffic. But I saw Ryan Lubke's post yesterday. So I thought I'll ask the question here and if there is a better place where Grizzly related discussions are happening, please point me to that location.

I'm trying to write a WebSocket client that establishes permanent secure (wss://) connections to a WebSocket server using the Grizzly framework.

I have several meta-questions and a real question:

Meta-Q1: The WebSockets chapter of the Grizzly documentation points me to Ryan's blog entry "Async HTTP Client 1.7.0 Released. Details on the Grizzly Side of Things…" ( It was written in January 2012. Is it still current?

Meta-Q2: The blog entry points to the Maven dependency:


I saw that version 1.3 of the same package is available at Maven Central. I assume it is OK to use 1.3. Am I right?

Meta-Q3: Why is grizzly-http-client not versioned like the rest of the Grizzly components? Is it somehow less of an integral part of the Grizzly framework?
I wanted to keep it separate as the Async HTTP Client release schedule differs from ours.  It wouldn't make sense to release a new version when nothing changed.

Meta-Q4: The grizzly-http-client-1.3-sources.jar that I got from Maven Central contains only one Java source file, that of org/glassfish/grizzly/http/ Where can I get the rest of the sources from Maven Central?
I would recommend getting the source bundle for Async HTTP Client 1.7.6.

Q1: I create the WebSocket using the following code:

AsyncHttpClientConfig asyncHttpClientConfig =
new AsyncHttpClientConfig.Builder()
AsyncHttpClient asyncHttpClient =
new AsyncHttpClient(new GrizzlyAsyncHttpProvider(asyncHttpClientConfig), asyncHttpClientConfig);
WebSocketListener webSocketListener = new DefaultWebSocketListener() {
// my processing
WebSocketUpgradeHandler handler =
new WebSocketUpgradeHandler.Builder()
String wsUrl = "wss://localhost/context";
WebSocket webSocket = asyncHttpClient.prepareGet(wsUrl).execute(handler).get();

It successfully connects to the server and establishes the connection, over which the client was able to exchange data with the server. However, after a minute or so, the IdleTimeoutFilter that was instantiated here

<init>():129, IdleTimeoutFilter {org.glassfish.grizzly.utils}
initializeTransport():346, GrizzlyAsyncHttpProvider {com.ning.http.client.providers.grizzly}
<init>():176, GrizzlyAsyncHttpProvider {com.ning.http.client.providers.grizzly}

would fire and eventually close the WebSocket connection:

java.util.concurrent.TimeoutException: Timeout exceeded
at com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider.timeout(
at com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider$3.onTimeout(
at org.glassfish.grizzly.utils.IdleTimeoutFilter$DefaultWorker.doWork(
at org.glassfish.grizzly.utils.IdleTimeoutFilter$DefaultWorker.doWork(
at org.glassfish.grizzly.utils.DelayedExecutor$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$

What is the best way to get around my problem?
Set AsyncHttpClientConfig's requestTimeoutInMs property to -1.

Would also request logging an issue.  The logic should be disabling the timeout for ws connections.

WebSocket clinet with Grizzly

Weiqi Gao 05/02/2013

Re: WebSocket clinet with Grizzly

Ryan Lubke 05/02/2013

Re: WebSocket clinet with Grizzly

Weiqi Gao 05/02/2013

WebSocket server with Grizzly (was Re: WebSocket clinet with Grizzly)

Weiqi Gao 05/23/2013

Re: WebSocket server with Grizzly (was Re: WebSocket clinet with Grizzly)

Ryan Lubke 05/23/2013

Re: WebSocket server with Grizzly (was Re: WebSocket clinet with Grizzly)

Weiqi Gao 05/23/2013

Re: WebSocket server with Grizzly (was Re: WebSocket clinet with Grizzly)

Ryan Lubke 05/23/2013
Terms of Use; Privacy Policy; Copyright ©2013-2015 (revision 20150925.bf86fa7)
Please Confirm