Sharing code... It's basically the Echo example.
Tigran's solution worked. Please let me know if there's any other issues
spotted in my code.
Controller controller = new Controller();
TCPSelectorHandler tcpHandler = new TCPSelectorHandler(Role.SERVER);
//TCPSelectorHandler tcpHandler = new ReusableTCPSelectorHandler();
//Added thanks to Tigran
DefaultSelectionKeyHandler keyHandler = new
DefaultSelectionKeyHandler();
keyHandler.setTimeout(-1);
tcpHandler.setSelectionKeyHandler(keyHandler);
// My own timeout setting stuff
tcpHandler.setKeepAlive(true);
tcpHandler.setLinger(1);
tcpHandler.getLogger().setLevel(Level.ALL);
//System.out.println(tcpHandler.isKeepAlive());
//System.out.println(tcpHandler.getSelectTimeout());
final FooProtocolFilter filter = new FooProtocolFilter();
tcpHandler.setPort(port);
controller.setProtocolChainInstanceHandler(new
DefaultProtocolChainInstanceHandler() {
public ProtocolChain poll() {
ProtocolChain protocolChain = protocolChains.poll();
if (protocolChain == null) {
protocolChain = new DefaultProtocolChain();
com.sun.grizzly.filter.ReadFilter rf;
rf = new ReadFilter();
rf.setContinuousExecution(true);
protocolChain.addFilter(rf);
protocolChain.addFilter(filter);
}
return protocolChain;
}
});
controller.addSelectorHandler(tcpHandler);
controller.start();
Oleksiy Stashok-2 wrote:
>
> Hi Keith,
>
> can you pls. share your code, or at least the Grizzly init part?
>
> Thank you.
>
> WBR,
> Alexey.
>
> On Oct 15, 2010, at 12:14 , Keith Shu wrote:
>
>> MY first time posting here.
>> I'm using Grizzly 1.9.19 to implement a socket server processing TCP
>> messages.
>> I used the example from echo filter. Everything works great except
>> one issue.
>> When the client is idle - (not sending any messages) the connection
>> terminates after about 2 minutes.
>> Is this by design? I've looked at all the timeout settings and keep
>> alives but all seems ok to me.
>>
>> I think you can recreate this by running Echo filter, then open a
>> telnet to the port but don't send any message.
>> How can i make the connection persist even when there's no message
>> passed.
>>
>> Thanks in advance for responses. Hope it can be prompt.
>> Keith
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>
>
>
--
View this message in context: http://old.nabble.com/Grizzly-Idle-timeout-tp29970341p29987031.html
Sent from the Grizzly - Users mailing list archive at Nabble.com.