ReadTimeoutHandler for websocket connection

210 views
Skip to first unread message

john mayer

unread,
Dec 15, 2014, 11:13:13 PM12/15/14
to ne...@googlegroups.com
Hi,
    i  am working on websocket server. i have found an exmple https://github.com/netty/netty/blob/master/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServer.java. I am trying using same handler for http polling too. i want to apply readtimeout handler only for websocket connection not for http connection. how can i do that?

이희승 (Trustin Lee)

unread,
Jan 21, 2015, 4:22:19 AM1/21/15
to ne...@googlegroups.com
You could prepare three `ReadTimeoutHandler` for this.
 
The first one is to time-out the connection when you are unsure if it's a plain HTTP connection or a Web Socket connection.
The second one is to time-out the plain HTTP connection.
The third one is to time-out the Web Socket connection.
 
Presumably, the first one and the second one might have the same timeout. Then you need only two ReadTimeoutHandlers.
 
Your pipeline starts with the first timeout handler, because you don't know which the current connection is.
 
When the client sends an HTTP request, you can determine if the current connection is Web Socket or not.
 
If the current connection is plain HTTP, you can replace the first timeout handler with the second timeout handler.  If the first one and the second one are same, then of course you don't need to do anything.
 
If the current connection is Web Socket, you can replace the first timeout handler with the third timeout handler.
 
Because a Web Socket connection can be created in the middle of the plain HTTP keep-alive connection, you might end up replacing the timeout handlers twice. (first -> second -> third)
 
Please note you don't really need this sort of dynamic pipeline manipulation if you write your own timeout handler, which applies dynamic timeout based on the current HTTP message being processed, and it should be way more efficient.
 
HTH,
T
 
 
 
On Tue, Dec 16, 2014, at 01:13 PM, john mayer wrote:
Hi,
    i  am working on websocket server. i have found an exmple https://github.com/netty/netty/blob/master/example/src/main/java/io/netty/example/http/websocketx/server/WebSocketServer.java. I am trying using same handler for http polling too. i want to apply readtimeout handler only for websocket connection not for http connection. how can i do that?


--
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
 

john meyer

unread,
Jul 27, 2017, 2:28:02 PM7/27/17
to Netty discussions
@trustin,

Can you share the sample pipeline structure?
Reply all
Reply to author
Forward
0 new messages