You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Hardik Kubavat <ha...@primavera-software.com> on 2013/12/31 07:48:51 UTC

Return type of doDecode method

Hii

System.out.println("THIS IS FIRST DECODER");
         out.setAutoExpand(true);
         Listener l = (Listener)is.getAttribute("listener");
         byte[] bytes = new byte[ib.limit()];
         ib.get(bytes);
         if(l.getMessageType().equals("HL7"))
         {
             String s = new String(bytes);
             String hexString = toHexString(bytes);
             if(hexString.trim().startsWith("0B"))
             {
                 if(str.equals(""))
                 {
                     System.out.println("START");
                     str=s;
                 }else{
                     System.out.println("THERE IS BAD MESSAGE");
                     str=s;
                 }
             }else if(!hexString.trim().startsWith("0B")){
                 if(str.equals(""))
                 {
                     System.out.println("OTHER THAN HL7");
                     out.put(bytes);
                     out.flip();
                     pdo.write(out);
                     return false;
                 }else{
                     System.out.println("MIDDLE");
                     str = str + s;
                 }
             }
             if(hexString.trim().endsWith("0D")){
                 if(!str.equals(""))
                 {
                     System.out.println("END");
                     pdo.write(str);
                     str="";
                     return false;
                 }
             }
    return true;//or false
         }

This is the code for my first decoder. If it is other than HL7 then I am 
forwarding IoBuffer than protocol2 is executed
  my question is what is indicate by return type of doDocode

In This example if return true or false it has same behavior

Re: Unbind port for IoAcceptor is not working

Posted by "derek@user1.net" <de...@user1.net>.
I had been using acceptor.getSessionConfig().setReuseAddress(true) which I
must have culled from a post somewhere in an attempt to solve the problem.
I can see now from the NioSocketAcceptor source code that the
SocketAcceptor version maps directly to the equivalent method on
ServerSocket.

So after changing my code to: acceptor.setReuseAddress(true) it seems to
have solved the problem.

Thanks much Emmanuel and Jeff!

Derek


On Mon, Jan 27, 2014 at 7:14 PM, Emmanuel Lécharny <el...@gmail.com>wrote:

> Have you called the setReuseAddress() with true as a parameter when you
> created and initialized the service ?
>
>
> Le 1/27/14 11:29 PM, derek@user1.net a écrit :
> > My apologies. The server uses multiple SocketAcceptors (another one being
> > on port 10110) and I mixed them up when sending them to you.
> >
> > Here is the info again for 10100 and binding to a single local address...
> >
> > After bind:
> >
> > tcp6       0      0 118-173.111.65.se:10100 *:*
> LISTEN
> >
> > After client connection:
> >
> > tcp6       0      0 118-173.111.65.se:10100 *:*
> LISTEN
> > tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51964
> > ESTABLISHED
> >
> > After shutdown:
> >
> > tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51964
> > TIME_WAIT
> >
> > Again sorry for the confusion,
> >
> > Derek
> >
> >
> >
> > On Mon, Jan 27, 2014 at 5:12 PM, Jeff MAURY <je...@jeffmaury.com>
> wrote:
> >
> >> Do you have an idea where the connection from localhost:4422 come from
> as
> >> it was not listed when the JVM was running ?
> >>
> >> Jeff
> >>
> >>
> >> On Mon, Jan 27, 2014 at 11:05 PM, derek@user1.net <de...@user1.net>
> wrote:
> >>
> >>> O/S I'm currently testing on is Debian Linux 4.0 but I've seen this
> occur
> >>> on other flavours of Linux as well but off-hand can't say if it's 100%.
> >>>
> >>> In my tests the SocketAcceptor is binding to 10100 on all local
> >> addresses.
> >>> After bind:
> >>>
> >>> tcp6       0      0 *:10110                 *:*
> >> LISTEN
> >>> After the client connects:
> >>>
> >>> tcp6       0      0 *:10110                 *:*
> >> LISTEN
> >>> tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51693
> >>> ESTABLISHED
> >>>
> >>> After shutdown:
> >>>
> >>> tcp6       0      0 localhost:10110         localhost:4422
> >>>  TIME_WAIT
> >>> tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51693
> >>> TIME_WAIT
> >>>
> >>> Thanks,
> >>>
> >>> Derek
> >>>
> >>>
> >>> On Mon, Jan 27, 2014 at 4:32 PM, Jeff MAURY <je...@jeffmaury.com>
> >>> wrote:
> >>>
> >>>> On which platform your server (acceptor) is running.
> >>>> Can you check the output of netstat after your server JVM has been
> shut
> >>>> down ?
> >>>>
> >>>> Jeff
> >>>>
> >>>>
> >>>> On Mon, Jan 27, 2014 at 10:29 PM, derek@user1.net <de...@user1.net>
> >>> wrote:
> >>>>> Hello,
> >>>>>
> >>>>> I realize the original should be in the users mailing list but
> >> replying
> >>>>> here to keep the thread intact.
> >>>>>
> >>>>> I have been observing the same issue:
> >>>>>
> >>>>> - bind() a SocketAcceptor to an address
> >>>>> - connect a client to the SocketAcceptor
> >>>>> - while the client is connected call dispose() and then unbind() (and
> >>>> tried
> >>>>> also with unbind(true)) on the SocketAcceptor
> >>>>> - here the vm is terminated and the program restarted
> >>>>> - attempting to bind() to the same address results in a
> >>>>> "java.net.BindException: Address already in use" 100% of the time.
> >>>>>
> >>>>> I have even tried dispose() then iterating over ever managed session
> >>> and
> >>>>> calling IoSession.close() and then unbind(). Same result.
> >>>>>
> >>>>> Regards,
> >>>>>
> >>>>> Derek
> >>>>>
> >>>>>
> >>>>>
> >>>>> On Mon, Jan 27, 2014 at 4:44 AM, Emmanuel Lécharny <
> >>> elecharny@gmail.com
> >>>>>> wrote:
> >>>>>> Hi,
> >>>>>>
> >>>>>> FTR, dev list is not the right place for such mail. Please use the
> >>>> users
> >>>>>> mailing list.
> >>>>>>
> >>>>>> Have you disposed the acceptor before unbinding it ? If there is
> >> any
> >>>>>> pending connection, it's likely that the socket will be persisted
> >>> even
> >>>>>> after an Unbind, for the socket timeout (which might be quite
> >> long).
> >>>>>> Always close correctly all the sessions programmatically before
> >>>>>> unbinding. Dispose do that.
> >>>>>>
> >>>>>>
> >>>>>> Le 1/27/14 10:23 AM, Hardik Kubavat a écrit :
> >>>>>>> Hi,
> >>>>>>>
> >>>>>>> I am unbind the port from IoAcceptor using
> >>>>>>>
> >>>>>>> ==>    acceptor.unbind(new InetSocketAddress(portNo));
> >>>>>>>
> >>>>>>> So when we try to bind this same port on acceptor it's throws
> >>>>>>> Exception with Following message
> >>>>>>> Address already in use.
> >>>>>>>
> >>>>>>> As per my requirement I need to bind and unbind port dynamically.
> >>> And
> >>>>>>> It is possible that same port we need to unbind and than bind
> >>> again.
> >>>>>>
> >>>>>> --
> >>>>>> Regards,
> >>>>>> Cordialement,
> >>>>>> Emmanuel Lécharny
> >>>>>> www.iktek.com
> >>>>>>
> >>>>>>
> >>>>
> >>>>
> >>>> --
> >>>> Jeff MAURY
> >>>>
> >>>>
> >>>> "Legacy code" often differs from its suggested alternative by actually
> >>>> working and scaling.
> >>>>  - Bjarne Stroustrup
> >>>>
> >>>> http://www.jeffmaury.com
> >>>> http://riadiscuss.jeffmaury.com
> >>>> http://www.twitter.com/jeffmaury
> >>>>
> >>
> >>
> >> --
> >> Jeff MAURY
> >>
> >>
> >> "Legacy code" often differs from its suggested alternative by actually
> >> working and scaling.
> >>  - Bjarne Stroustrup
> >>
> >> http://www.jeffmaury.com
> >> http://riadiscuss.jeffmaury.com
> >> http://www.twitter.com/jeffmaury
> >>
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>

Re: Unbind port for IoAcceptor is not working

Posted by Emmanuel Lécharny <el...@gmail.com>.
Have you called the setReuseAddress() with true as a parameter when you
created and initialized the service ?


Le 1/27/14 11:29 PM, derek@user1.net a écrit :
> My apologies. The server uses multiple SocketAcceptors (another one being
> on port 10110) and I mixed them up when sending them to you.
>
> Here is the info again for 10100 and binding to a single local address...
>
> After bind:
>
> tcp6       0      0 118-173.111.65.se:10100 *:*                     LISTEN
>
> After client connection:
>
> tcp6       0      0 118-173.111.65.se:10100 *:*                     LISTEN
> tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51964
> ESTABLISHED
>
> After shutdown:
>
> tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51964
> TIME_WAIT
>
> Again sorry for the confusion,
>
> Derek
>
>
>
> On Mon, Jan 27, 2014 at 5:12 PM, Jeff MAURY <je...@jeffmaury.com> wrote:
>
>> Do you have an idea where the connection from localhost:4422 come from as
>> it was not listed when the JVM was running ?
>>
>> Jeff
>>
>>
>> On Mon, Jan 27, 2014 at 11:05 PM, derek@user1.net <de...@user1.net> wrote:
>>
>>> O/S I'm currently testing on is Debian Linux 4.0 but I've seen this occur
>>> on other flavours of Linux as well but off-hand can't say if it's 100%.
>>>
>>> In my tests the SocketAcceptor is binding to 10100 on all local
>> addresses.
>>> After bind:
>>>
>>> tcp6       0      0 *:10110                 *:*
>> LISTEN
>>> After the client connects:
>>>
>>> tcp6       0      0 *:10110                 *:*
>> LISTEN
>>> tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51693
>>> ESTABLISHED
>>>
>>> After shutdown:
>>>
>>> tcp6       0      0 localhost:10110         localhost:4422
>>>  TIME_WAIT
>>> tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51693
>>> TIME_WAIT
>>>
>>> Thanks,
>>>
>>> Derek
>>>
>>>
>>> On Mon, Jan 27, 2014 at 4:32 PM, Jeff MAURY <je...@jeffmaury.com>
>>> wrote:
>>>
>>>> On which platform your server (acceptor) is running.
>>>> Can you check the output of netstat after your server JVM has been shut
>>>> down ?
>>>>
>>>> Jeff
>>>>
>>>>
>>>> On Mon, Jan 27, 2014 at 10:29 PM, derek@user1.net <de...@user1.net>
>>> wrote:
>>>>> Hello,
>>>>>
>>>>> I realize the original should be in the users mailing list but
>> replying
>>>>> here to keep the thread intact.
>>>>>
>>>>> I have been observing the same issue:
>>>>>
>>>>> - bind() a SocketAcceptor to an address
>>>>> - connect a client to the SocketAcceptor
>>>>> - while the client is connected call dispose() and then unbind() (and
>>>> tried
>>>>> also with unbind(true)) on the SocketAcceptor
>>>>> - here the vm is terminated and the program restarted
>>>>> - attempting to bind() to the same address results in a
>>>>> "java.net.BindException: Address already in use" 100% of the time.
>>>>>
>>>>> I have even tried dispose() then iterating over ever managed session
>>> and
>>>>> calling IoSession.close() and then unbind(). Same result.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Derek
>>>>>
>>>>>
>>>>>
>>>>> On Mon, Jan 27, 2014 at 4:44 AM, Emmanuel Lécharny <
>>> elecharny@gmail.com
>>>>>> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> FTR, dev list is not the right place for such mail. Please use the
>>>> users
>>>>>> mailing list.
>>>>>>
>>>>>> Have you disposed the acceptor before unbinding it ? If there is
>> any
>>>>>> pending connection, it's likely that the socket will be persisted
>>> even
>>>>>> after an Unbind, for the socket timeout (which might be quite
>> long).
>>>>>> Always close correctly all the sessions programmatically before
>>>>>> unbinding. Dispose do that.
>>>>>>
>>>>>>
>>>>>> Le 1/27/14 10:23 AM, Hardik Kubavat a écrit :
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am unbind the port from IoAcceptor using
>>>>>>>
>>>>>>> ==>    acceptor.unbind(new InetSocketAddress(portNo));
>>>>>>>
>>>>>>> So when we try to bind this same port on acceptor it's throws
>>>>>>> Exception with Following message
>>>>>>> Address already in use.
>>>>>>>
>>>>>>> As per my requirement I need to bind and unbind port dynamically.
>>> And
>>>>>>> It is possible that same port we need to unbind and than bind
>>> again.
>>>>>>
>>>>>> --
>>>>>> Regards,
>>>>>> Cordialement,
>>>>>> Emmanuel Lécharny
>>>>>> www.iktek.com
>>>>>>
>>>>>>
>>>>
>>>>
>>>> --
>>>> Jeff MAURY
>>>>
>>>>
>>>> "Legacy code" often differs from its suggested alternative by actually
>>>> working and scaling.
>>>>  - Bjarne Stroustrup
>>>>
>>>> http://www.jeffmaury.com
>>>> http://riadiscuss.jeffmaury.com
>>>> http://www.twitter.com/jeffmaury
>>>>
>>
>>
>> --
>> Jeff MAURY
>>
>>
>> "Legacy code" often differs from its suggested alternative by actually
>> working and scaling.
>>  - Bjarne Stroustrup
>>
>> http://www.jeffmaury.com
>> http://riadiscuss.jeffmaury.com
>> http://www.twitter.com/jeffmaury
>>


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com 


Re: Unbind port for IoAcceptor is not working

Posted by "derek@user1.net" <de...@user1.net>.
My apologies. The server uses multiple SocketAcceptors (another one being
on port 10110) and I mixed them up when sending them to you.

Here is the info again for 10100 and binding to a single local address...

After bind:

tcp6       0      0 118-173.111.65.se:10100 *:*                     LISTEN

After client connection:

tcp6       0      0 118-173.111.65.se:10100 *:*                     LISTEN
tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51964
ESTABLISHED

After shutdown:

tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51964
TIME_WAIT

Again sorry for the confusion,

Derek



On Mon, Jan 27, 2014 at 5:12 PM, Jeff MAURY <je...@jeffmaury.com> wrote:

> Do you have an idea where the connection from localhost:4422 come from as
> it was not listed when the JVM was running ?
>
> Jeff
>
>
> On Mon, Jan 27, 2014 at 11:05 PM, derek@user1.net <de...@user1.net> wrote:
>
> > O/S I'm currently testing on is Debian Linux 4.0 but I've seen this occur
> > on other flavours of Linux as well but off-hand can't say if it's 100%.
> >
> > In my tests the SocketAcceptor is binding to 10100 on all local
> addresses.
> >
> > After bind:
> >
> > tcp6       0      0 *:10110                 *:*
> LISTEN
> >
> > After the client connects:
> >
> > tcp6       0      0 *:10110                 *:*
> LISTEN
> > tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51693
> > ESTABLISHED
> >
> > After shutdown:
> >
> > tcp6       0      0 localhost:10110         localhost:4422
> >  TIME_WAIT
> > tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51693
> > TIME_WAIT
> >
> > Thanks,
> >
> > Derek
> >
> >
> > On Mon, Jan 27, 2014 at 4:32 PM, Jeff MAURY <je...@jeffmaury.com>
> > wrote:
> >
> > > On which platform your server (acceptor) is running.
> > > Can you check the output of netstat after your server JVM has been shut
> > > down ?
> > >
> > > Jeff
> > >
> > >
> > > On Mon, Jan 27, 2014 at 10:29 PM, derek@user1.net <de...@user1.net>
> > wrote:
> > >
> > > > Hello,
> > > >
> > > > I realize the original should be in the users mailing list but
> replying
> > > > here to keep the thread intact.
> > > >
> > > > I have been observing the same issue:
> > > >
> > > > - bind() a SocketAcceptor to an address
> > > > - connect a client to the SocketAcceptor
> > > > - while the client is connected call dispose() and then unbind() (and
> > > tried
> > > > also with unbind(true)) on the SocketAcceptor
> > > > - here the vm is terminated and the program restarted
> > > > - attempting to bind() to the same address results in a
> > > > "java.net.BindException: Address already in use" 100% of the time.
> > > >
> > > > I have even tried dispose() then iterating over ever managed session
> > and
> > > > calling IoSession.close() and then unbind(). Same result.
> > > >
> > > > Regards,
> > > >
> > > > Derek
> > > >
> > > >
> > > >
> > > > On Mon, Jan 27, 2014 at 4:44 AM, Emmanuel Lécharny <
> > elecharny@gmail.com
> > > > >wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > FTR, dev list is not the right place for such mail. Please use the
> > > users
> > > > > mailing list.
> > > > >
> > > > > Have you disposed the acceptor before unbinding it ? If there is
> any
> > > > > pending connection, it's likely that the socket will be persisted
> > even
> > > > > after an Unbind, for the socket timeout (which might be quite
> long).
> > > > >
> > > > > Always close correctly all the sessions programmatically before
> > > > > unbinding. Dispose do that.
> > > > >
> > > > >
> > > > > Le 1/27/14 10:23 AM, Hardik Kubavat a écrit :
> > > > > > Hi,
> > > > > >
> > > > > > I am unbind the port from IoAcceptor using
> > > > > >
> > > > > > ==>    acceptor.unbind(new InetSocketAddress(portNo));
> > > > > >
> > > > > > So when we try to bind this same port on acceptor it's throws
> > > > > > Exception with Following message
> > > > > > Address already in use.
> > > > > >
> > > > > > As per my requirement I need to bind and unbind port dynamically.
> > And
> > > > > > It is possible that same port we need to unbind and than bind
> > again.
> > > > >
> > > > >
> > > > > --
> > > > > Regards,
> > > > > Cordialement,
> > > > > Emmanuel Lécharny
> > > > > www.iktek.com
> > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Jeff MAURY
> > >
> > >
> > > "Legacy code" often differs from its suggested alternative by actually
> > > working and scaling.
> > >  - Bjarne Stroustrup
> > >
> > > http://www.jeffmaury.com
> > > http://riadiscuss.jeffmaury.com
> > > http://www.twitter.com/jeffmaury
> > >
> >
>
>
>
> --
> Jeff MAURY
>
>
> "Legacy code" often differs from its suggested alternative by actually
> working and scaling.
>  - Bjarne Stroustrup
>
> http://www.jeffmaury.com
> http://riadiscuss.jeffmaury.com
> http://www.twitter.com/jeffmaury
>

Re: Unbind port for IoAcceptor is not working

Posted by Jeff MAURY <je...@jeffmaury.com>.
Do you have an idea where the connection from localhost:4422 come from as
it was not listed when the JVM was running ?

Jeff


On Mon, Jan 27, 2014 at 11:05 PM, derek@user1.net <de...@user1.net> wrote:

> O/S I'm currently testing on is Debian Linux 4.0 but I've seen this occur
> on other flavours of Linux as well but off-hand can't say if it's 100%.
>
> In my tests the SocketAcceptor is binding to 10100 on all local addresses.
>
> After bind:
>
> tcp6       0      0 *:10110                 *:*                     LISTEN
>
> After the client connects:
>
> tcp6       0      0 *:10110                 *:*                     LISTEN
> tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51693
> ESTABLISHED
>
> After shutdown:
>
> tcp6       0      0 localhost:10110         localhost:4422
>  TIME_WAIT
> tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51693
> TIME_WAIT
>
> Thanks,
>
> Derek
>
>
> On Mon, Jan 27, 2014 at 4:32 PM, Jeff MAURY <je...@jeffmaury.com>
> wrote:
>
> > On which platform your server (acceptor) is running.
> > Can you check the output of netstat after your server JVM has been shut
> > down ?
> >
> > Jeff
> >
> >
> > On Mon, Jan 27, 2014 at 10:29 PM, derek@user1.net <de...@user1.net>
> wrote:
> >
> > > Hello,
> > >
> > > I realize the original should be in the users mailing list but replying
> > > here to keep the thread intact.
> > >
> > > I have been observing the same issue:
> > >
> > > - bind() a SocketAcceptor to an address
> > > - connect a client to the SocketAcceptor
> > > - while the client is connected call dispose() and then unbind() (and
> > tried
> > > also with unbind(true)) on the SocketAcceptor
> > > - here the vm is terminated and the program restarted
> > > - attempting to bind() to the same address results in a
> > > "java.net.BindException: Address already in use" 100% of the time.
> > >
> > > I have even tried dispose() then iterating over ever managed session
> and
> > > calling IoSession.close() and then unbind(). Same result.
> > >
> > > Regards,
> > >
> > > Derek
> > >
> > >
> > >
> > > On Mon, Jan 27, 2014 at 4:44 AM, Emmanuel Lécharny <
> elecharny@gmail.com
> > > >wrote:
> > >
> > > > Hi,
> > > >
> > > > FTR, dev list is not the right place for such mail. Please use the
> > users
> > > > mailing list.
> > > >
> > > > Have you disposed the acceptor before unbinding it ? If there is any
> > > > pending connection, it's likely that the socket will be persisted
> even
> > > > after an Unbind, for the socket timeout (which might be quite long).
> > > >
> > > > Always close correctly all the sessions programmatically before
> > > > unbinding. Dispose do that.
> > > >
> > > >
> > > > Le 1/27/14 10:23 AM, Hardik Kubavat a écrit :
> > > > > Hi,
> > > > >
> > > > > I am unbind the port from IoAcceptor using
> > > > >
> > > > > ==>    acceptor.unbind(new InetSocketAddress(portNo));
> > > > >
> > > > > So when we try to bind this same port on acceptor it's throws
> > > > > Exception with Following message
> > > > > Address already in use.
> > > > >
> > > > > As per my requirement I need to bind and unbind port dynamically.
> And
> > > > > It is possible that same port we need to unbind and than bind
> again.
> > > >
> > > >
> > > > --
> > > > Regards,
> > > > Cordialement,
> > > > Emmanuel Lécharny
> > > > www.iktek.com
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > Jeff MAURY
> >
> >
> > "Legacy code" often differs from its suggested alternative by actually
> > working and scaling.
> >  - Bjarne Stroustrup
> >
> > http://www.jeffmaury.com
> > http://riadiscuss.jeffmaury.com
> > http://www.twitter.com/jeffmaury
> >
>



-- 
Jeff MAURY


"Legacy code" often differs from its suggested alternative by actually
working and scaling.
 - Bjarne Stroustrup

http://www.jeffmaury.com
http://riadiscuss.jeffmaury.com
http://www.twitter.com/jeffmaury

Re: Unbind port for IoAcceptor is not working

Posted by "derek@user1.net" <de...@user1.net>.
O/S I'm currently testing on is Debian Linux 4.0 but I've seen this occur
on other flavours of Linux as well but off-hand can't say if it's 100%.

In my tests the SocketAcceptor is binding to 10100 on all local addresses.

After bind:

tcp6       0      0 *:10110                 *:*                     LISTEN

After the client connects:

tcp6       0      0 *:10110                 *:*                     LISTEN
tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51693
ESTABLISHED

After shutdown:

tcp6       0      0 localhost:10110         localhost:4422
 TIME_WAIT
tcp6       0      0 118-173.111.65.se:10100 CPEc8d3a35c2eb4-C:51693
TIME_WAIT

Thanks,

Derek


On Mon, Jan 27, 2014 at 4:32 PM, Jeff MAURY <je...@jeffmaury.com> wrote:

> On which platform your server (acceptor) is running.
> Can you check the output of netstat after your server JVM has been shut
> down ?
>
> Jeff
>
>
> On Mon, Jan 27, 2014 at 10:29 PM, derek@user1.net <de...@user1.net> wrote:
>
> > Hello,
> >
> > I realize the original should be in the users mailing list but replying
> > here to keep the thread intact.
> >
> > I have been observing the same issue:
> >
> > - bind() a SocketAcceptor to an address
> > - connect a client to the SocketAcceptor
> > - while the client is connected call dispose() and then unbind() (and
> tried
> > also with unbind(true)) on the SocketAcceptor
> > - here the vm is terminated and the program restarted
> > - attempting to bind() to the same address results in a
> > "java.net.BindException: Address already in use" 100% of the time.
> >
> > I have even tried dispose() then iterating over ever managed session and
> > calling IoSession.close() and then unbind(). Same result.
> >
> > Regards,
> >
> > Derek
> >
> >
> >
> > On Mon, Jan 27, 2014 at 4:44 AM, Emmanuel Lécharny <elecharny@gmail.com
> > >wrote:
> >
> > > Hi,
> > >
> > > FTR, dev list is not the right place for such mail. Please use the
> users
> > > mailing list.
> > >
> > > Have you disposed the acceptor before unbinding it ? If there is any
> > > pending connection, it's likely that the socket will be persisted even
> > > after an Unbind, for the socket timeout (which might be quite long).
> > >
> > > Always close correctly all the sessions programmatically before
> > > unbinding. Dispose do that.
> > >
> > >
> > > Le 1/27/14 10:23 AM, Hardik Kubavat a écrit :
> > > > Hi,
> > > >
> > > > I am unbind the port from IoAcceptor using
> > > >
> > > > ==>    acceptor.unbind(new InetSocketAddress(portNo));
> > > >
> > > > So when we try to bind this same port on acceptor it's throws
> > > > Exception with Following message
> > > > Address already in use.
> > > >
> > > > As per my requirement I need to bind and unbind port dynamically. And
> > > > It is possible that same port we need to unbind and than bind again.
> > >
> > >
> > > --
> > > Regards,
> > > Cordialement,
> > > Emmanuel Lécharny
> > > www.iktek.com
> > >
> > >
> >
>
>
>
> --
> Jeff MAURY
>
>
> "Legacy code" often differs from its suggested alternative by actually
> working and scaling.
>  - Bjarne Stroustrup
>
> http://www.jeffmaury.com
> http://riadiscuss.jeffmaury.com
> http://www.twitter.com/jeffmaury
>

Re: Unbind port for IoAcceptor is not working

Posted by Jeff MAURY <je...@jeffmaury.com>.
On which platform your server (acceptor) is running.
Can you check the output of netstat after your server JVM has been shut
down ?

Jeff


On Mon, Jan 27, 2014 at 10:29 PM, derek@user1.net <de...@user1.net> wrote:

> Hello,
>
> I realize the original should be in the users mailing list but replying
> here to keep the thread intact.
>
> I have been observing the same issue:
>
> - bind() a SocketAcceptor to an address
> - connect a client to the SocketAcceptor
> - while the client is connected call dispose() and then unbind() (and tried
> also with unbind(true)) on the SocketAcceptor
> - here the vm is terminated and the program restarted
> - attempting to bind() to the same address results in a
> "java.net.BindException: Address already in use" 100% of the time.
>
> I have even tried dispose() then iterating over ever managed session and
> calling IoSession.close() and then unbind(). Same result.
>
> Regards,
>
> Derek
>
>
>
> On Mon, Jan 27, 2014 at 4:44 AM, Emmanuel Lécharny <elecharny@gmail.com
> >wrote:
>
> > Hi,
> >
> > FTR, dev list is not the right place for such mail. Please use the users
> > mailing list.
> >
> > Have you disposed the acceptor before unbinding it ? If there is any
> > pending connection, it's likely that the socket will be persisted even
> > after an Unbind, for the socket timeout (which might be quite long).
> >
> > Always close correctly all the sessions programmatically before
> > unbinding. Dispose do that.
> >
> >
> > Le 1/27/14 10:23 AM, Hardik Kubavat a écrit :
> > > Hi,
> > >
> > > I am unbind the port from IoAcceptor using
> > >
> > > ==>    acceptor.unbind(new InetSocketAddress(portNo));
> > >
> > > So when we try to bind this same port on acceptor it's throws
> > > Exception with Following message
> > > Address already in use.
> > >
> > > As per my requirement I need to bind and unbind port dynamically. And
> > > It is possible that same port we need to unbind and than bind again.
> >
> >
> > --
> > Regards,
> > Cordialement,
> > Emmanuel Lécharny
> > www.iktek.com
> >
> >
>



-- 
Jeff MAURY


"Legacy code" often differs from its suggested alternative by actually
working and scaling.
 - Bjarne Stroustrup

http://www.jeffmaury.com
http://riadiscuss.jeffmaury.com
http://www.twitter.com/jeffmaury

Re: Unbind port for IoAcceptor is not working

Posted by "derek@user1.net" <de...@user1.net>.
Hello,

I realize the original should be in the users mailing list but replying
here to keep the thread intact.

I have been observing the same issue:

- bind() a SocketAcceptor to an address
- connect a client to the SocketAcceptor
- while the client is connected call dispose() and then unbind() (and tried
also with unbind(true)) on the SocketAcceptor
- here the vm is terminated and the program restarted
- attempting to bind() to the same address results in a
"java.net.BindException: Address already in use" 100% of the time.

I have even tried dispose() then iterating over ever managed session and
calling IoSession.close() and then unbind(). Same result.

Regards,

Derek



On Mon, Jan 27, 2014 at 4:44 AM, Emmanuel Lécharny <el...@gmail.com>wrote:

> Hi,
>
> FTR, dev list is not the right place for such mail. Please use the users
> mailing list.
>
> Have you disposed the acceptor before unbinding it ? If there is any
> pending connection, it's likely that the socket will be persisted even
> after an Unbind, for the socket timeout (which might be quite long).
>
> Always close correctly all the sessions programmatically before
> unbinding. Dispose do that.
>
>
> Le 1/27/14 10:23 AM, Hardik Kubavat a écrit :
> > Hi,
> >
> > I am unbind the port from IoAcceptor using
> >
> > ==>    acceptor.unbind(new InetSocketAddress(portNo));
> >
> > So when we try to bind this same port on acceptor it's throws
> > Exception with Following message
> > Address already in use.
> >
> > As per my requirement I need to bind and unbind port dynamically. And
> > It is possible that same port we need to unbind and than bind again.
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>

Re: Unbind port for IoAcceptor is not working

Posted by Emmanuel Lécharny <el...@gmail.com>.
Hi,

FTR, dev list is not the right place for such mail. Please use the users
mailing list.

Have you disposed the acceptor before unbinding it ? If there is any
pending connection, it's likely that the socket will be persisted even
after an Unbind, for the socket timeout (which might be quite long).

Always close correctly all the sessions programmatically before
unbinding. Dispose do that.


Le 1/27/14 10:23 AM, Hardik Kubavat a écrit :
> Hi,
>
> I am unbind the port from IoAcceptor using
>
> ==>    acceptor.unbind(new InetSocketAddress(portNo));
>
> So when we try to bind this same port on acceptor it's throws
> Exception with Following message
> Address already in use.
>
> As per my requirement I need to bind and unbind port dynamically. And
> It is possible that same port we need to unbind and than bind again.


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com 


Unbind port for IoAcceptor is not working

Posted by Hardik Kubavat <ha...@primavera-software.com>.
Hi,

I am unbind the port from IoAcceptor using

==>    acceptor.unbind(new InetSocketAddress(portNo));

So when we try to bind this same port on acceptor it's throws Exception 
with Following message
Address already in use.

As per my requirement I need to bind and unbind port dynamically. And It 
is possible that same port we need to unbind and than bind again.

Re: Return type of doDecode method

Posted by Emmanuel Lécharny <el...@gmail.com>.
It's hard to tell what's wrong with your code, as it's not complete and
it won't build at all due to missing declarations of variabe.

Anyway. The doDecode method returns true when the message has been fully
decoded, and false if not. If you get a false, then the following
decoder won't be called at all.

I question the need for you to use CumulativeProtocolDecoder, which will
wait until they have received all the data needed to actually decode a
message...

I advise you to keep it simple as possible.


Le 12/31/13 7:48 AM, Hardik Kubavat a écrit :
> Hii
>
> System.out.println("THIS IS FIRST DECODER");
>         out.setAutoExpand(true);
>         Listener l = (Listener)is.getAttribute("listener");
>         byte[] bytes = new byte[ib.limit()];
>         ib.get(bytes);
>         if(l.getMessageType().equals("HL7"))
>         {
>             String s = new String(bytes);
>             String hexString = toHexString(bytes);
>             if(hexString.trim().startsWith("0B"))
>             {
>                 if(str.equals(""))
>                 {
>                     System.out.println("START");
>                     str=s;
>                 }else{
>                     System.out.println("THERE IS BAD MESSAGE");
>                     str=s;
>                 }
>             }else if(!hexString.trim().startsWith("0B")){
>                 if(str.equals(""))
>                 {
>                     System.out.println("OTHER THAN HL7");
>                     out.put(bytes);
>                     out.flip();
>                     pdo.write(out);
>                     return false;
>                 }else{
>                     System.out.println("MIDDLE");
>                     str = str + s;
>                 }
>             }
>             if(hexString.trim().endsWith("0D")){
>                 if(!str.equals(""))
>                 {
>                     System.out.println("END");
>                     pdo.write(str);
>                     str="";
>                     return false;
>                 }
>             }
>    return true;//or false
>         }
>
> This is the code for my first decoder. If it is other than HL7 then I
> am forwarding IoBuffer than protocol2 is executed
>  my question is what is indicate by return type of doDocode
>
> In This example if return true or false it has same behavior
>


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com 


RE: Return type of doDecode method

Posted by Steve Ulrich <st...@proemion.com>.
Hi,

You should use the users mailing group, since the intention of this group is to discuss the further development on mina itself.

Seems like you need different decoders for different messages, so try using a MessageDecoder. You can specify multiple MessageDecoders at a DemuxingProtocolDecoder, that iterates through the decodable methods of the MDs, until any of them says OK. Then decode is called at that MD.

Some annotations to your code inside..

> Hardik Kubavat [mailto:hardik.kubavat@primavera-software.com] wrote:
>
> System.out.println("THIS IS FIRST DECODER");
>          out.setAutoExpand(true);
>          Listener l = (Listener)is.getAttribute("listener");
>          byte[] bytes = new byte[ib.limit()];
>          ib.get(bytes);
>          if(l.getMessageType().equals("HL7"))
>          {
>              String s = new String(bytes);

At least provide a charset, since the Charset used depends on the system (German system -> ISO-8859-15, US System -> US-ASCII, most linux systems -> utf-8)

>              String hexString = toHexString(bytes);
>              if(hexString.trim().startsWith("0B"))

Are you formatting your bytes as a hex string just to ask for a hex value? why don't you ask for:
if (bytes.lentgh > 0 && bytes[0] != 0x0B)

>              {
>                  if(str.equals(""))

I would recommend str.isEmpty(), just for the looks

>                  {
>                      System.out.println("START");
>                      str=s;
>                  }else{
>                      System.out.println("THERE IS BAD MESSAGE");
>                      str=s;
>                  }
>              }else if(!hexString.trim().startsWith("0B")){

You ask the exact negative from the if above, so it will return true all the time. the if from the else-if is completly superflous

>                  if(str.equals(""))
>                  {
>                      System.out.println("OTHER THAN HL7");
>                      out.put(bytes);
>                      out.flip();
>                      pdo.write(out);
>                      return false;
>                  }else{
>                      System.out.println("MIDDLE");
>                      str = str + s;
>                  }
>              }
>              if(hexString.trim().endsWith("0D")){
>                  if(!str.equals(""))
>                  {
>                      System.out.println("END");
>                      pdo.write(str);
>                      str="";
>                      return false;
>                  }
>              }
>     return true;//or false
>          }
>
> This is the code for my first decoder. If it is other than HL7 then I
> am forwarding IoBuffer than protocol2 is executed
>   my question is what is indicate by return type of doDocode
>
> In This example if return true or false it has same behavior
>