IoSession.close() closes the connection even if there's more data to write.
If you want to flush all data before closing the connection:

session.write(message).join(); // Make sure to call join() before calling
close()
session.close();

HTH,
Trustin

On 5/8/06, Niklas Therning <[EMAIL PROTECTED]> wrote:

As far as I know you should be able to write something right beore you
call close. I suspect that you're trying to write a non-ByteBuffer
message without having a codec for that type of message in the session's
filter chain. Could it be that when you refuse a connection like this
you don't add your codec filter to the session's filter chain?

Could you please post the complete stack trace of the thrown
IllegalStateException?

/Niklas

J2EE Professional wrote:
> ah..yes..i was writing something just before calling session.close().
thx for pointing out this..but just a question...since i have not closed the
session, how does it matter to the framework if i was writing just before
calling this session.close. hey one more question..i have two filters...i
want that filter no. 1 should be called after filter no2 . how do we acheive
this desired effect. e.g. in Web projects we simple  configure the filter
chain in web.xml and then when we say filter.getChain.doFilter the web
container calls our next filter in the filter chain..i hope i could make my
question clear.
>
> Niklas Therning <[EMAIL PROTECTED]> wrote: Seems like strange error.
Are you writing something right before you
> call session.close()? Could you post your code maybe?
>
> /Niklas
>
> J2EE Professional wrote:
>
>>right..i am doing that only...but i get the following exception when i
do session.close()
>>
>> java.lang.IllegalStateException: Write requests must be transformed to
class org.apache.mina.common.ByteBuffer:
>>
>> should i just catch this exception or is my approach (of doing
session.close()) an incorrect way of closing sessions ??
>>
>>
>>
>>Niklas Therning  wrote: Hi,
>>
>>You could implement your own IoFilter which keeps track of the number of
>>open connections and then refuses anymore connections when the threshold
>>has been reached. In your IoFilter you increment the counter everytime
>>sessionOpened is called and decrement the counter everytime
>>sessionClosed is called. If sessionOpened is called and the threshold
>>has been reached you just close the new session at once.
>>
>>HTH
>>
>>/Niklas
>>
>>J2EE Professional wrote:
>>
>>
>>>i am keeping a tab on the number of opened connections...why i reach a
threshold value i should forcefully close any more connections...how to do
this ?
>>>
>>>
>>>---------------------------------
>>>To help you stay safe and secure online, we've developed the all new
Yahoo! Security Centre.
>>
>>
>>
>>
>>
>>---------------------------------
>>Yahoo! 360° NEW – Your one place to blog, create, publish & share!
>
>
>
>
>
> ---------------------------------
>   24 FIFA World Cup tickets to be won with Yahoo! Mail. Learn more




--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Reply via email to