users@grizzly.java.net

Re: Implementing a NIO tunnel with Grizzly

From: Sam Crawford <samcrawford_at_gmail.com>
Date: Sun, 16 Aug 2009 21:39:50 +0100

Hi Oleksiy,

I've fired up the example you provided and it seems pretty
straightforward and works well.

However, when doing some quick tests via it I noted the following
exception was printed every so often... Is this something to be
concerned about? I was running this with the latest 2.0 SNAPSHOT.

Thanks

Sam

# java -cp "grizzly-framework-2.0.0-SNAPSHOT.jar:."
com.sun.grizzly.samples.tunnel.TunnelServer
Aug 16, 2009 9:33:31 PM com.sun.grizzly.samples.tunnel.TunnelServer main
INFO: Press any key to stop the server...
Aug 16, 2009 9:33:36 PM com.sun.grizzly.nio.transport.TCPNIOTransport
fireIOEvent
WARNING: Unexpected exception occurred
fireIOEvent().connection=com.sun.grizzly.nio.transport.TCPNIOConnection_at_785f8172
event=READ
java.nio.channels.CancelledKeyException
        at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:55)
        at sun.nio.ch.SelectionKeyImpl.interestOps(SelectionKeyImpl.java:64)
        at com.sun.grizzly.nio.DefaultSelectorHandler.unregisterKey0(DefaultSelectorHandler.java:216)
        at com.sun.grizzly.nio.DefaultSelectorHandler.unregisterKey(DefaultSelectorHandler.java:104)
        at com.sun.grizzly.nio.AbstractNIOConnection.disableIOEvent(AbstractNIOConnection.java:271)
        at com.sun.grizzly.nio.transport.TCPNIOTransport.executeDefaultProcessor(TCPNIOTransport.java:730)
        at com.sun.grizzly.nio.transport.TCPNIOTransport.processReadIoEvent(TCPNIOTransport.java:703)
        at com.sun.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:648)
        at com.sun.grizzly.nio.SelectorRunner.fire(SelectorRunner.java:385)
        at com.sun.grizzly.nio.SelectorRunner.iterateKeyEvents(SelectorRunner.java:317)
        at com.sun.grizzly.nio.SelectorRunner.iterateKeys(SelectorRunner.java:287)
        at com.sun.grizzly.nio.SelectorRunner.doSelect(SelectorRunner.java:259)
        at com.sun.grizzly.nio.SelectorRunner.run(SelectorRunner.java:190)
        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:619)






2009/8/12 Sam Crawford <samcrawford_at_gmail.com>:
> Brilliant, thank you very much! Hopefully I'll get started on this
> next month and you'll no doubt see me posting lots of questions here.
>
> Thanks,
>
> Sam
>
>
> 2009/8/11 Oleksiy Stashok <Oleksiy.Stashok_at_sun.com>:
>> Hi Sam,
>>
>>> I'm currently looking to rewrite our (blocking) tunneling software
>>> using NIO (in an effort to increase scalability), and Grizzly seems
>>> like it could save me a considerable amount of time. To be clear, this
>>> is for tunneling arbitrary TCP traffic (not just HTTP!), over both SSL
>>> and non-SSL.
>>>
>>> Having searched the archives, I see that someone else two years was
>>> interested in something similar
>>> (https://grizzly.dev.java.net/servlets/ReadMsg?listName=users&msgNo=52).
>>> Are the concepts largely the same nowadays? I know the Grizzly
>>> libraries have progressed a great deal since then, so I didn't want to
>>> dive too deeply into that if there were more appropriate ways of
>>> achieving this these days.
>>>
>>> Any other pointers would be most welcome!
>>
>> IMHO it should be pretty easy to write simple tunneling application.
>> All you'll need on server side - is to build filter chain and keep
>> client<->server connection map to redirect data among them.
>>
>> I've just created simple tunnel example for Grizzly 2.0, hope it will help.
>> To build them - please use the latest Grizzly 2.0 snapshot [2]
>>
>> WBR,
>> Alexey.
>>
>> [1]
>> https://grizzly.dev.java.net/source/browse/grizzly/branches/2dot0/code/samples/framework-samples/src/main/java/com/sun/grizzly/samples/tunnel/
>> [2]
>>    <groupId>com.sun.grizzly</groupId>
>>    <artifactId>grizzly-framework</artifactId>
>>    <version>2.0.0-SNAPSHOT</version>
>>
>>>
>>> Many thanks,
>>>
>>> Sam
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>