Also, interesting note.

I've now completed several runs where I switched the client's message to 
entirely lower case and had it go through.

This is a message:

051320130444256623|127.0.0.1|0.0.0.0|AAR|21|AAR=1=9=1223546|b1f5b76614959922401b798e3098cf30

I'm baffled as to what is happening that switching to lower case has absolutely 
anything whatsoever to do with whether or not the message comes through.

Thanks.

-----Original Message-----
From: Whitener, Winona T. [mailto:[email protected]] 
Sent: Monday, May 13, 2013 4:30 PM
To: [email protected]
Subject: RE: Help with NioSocketConnector

Please forgive wonky capitals.  I'm having to type this from computer to 
computer.  No exceptions are being recorded.  No exceptions are being caught.

It's definitely not the prettiest code and needs cleaning, but I am unable to 
track down why the connection is closing here.

Thank you for your help.

public class CodecFactory extends TextLineEncoder implements 
ProtocolCodecFactory {
        public static String EOM = "//endmsg//";
        public static String BOM = "//stmsg//";

        public ProtocolEncoder getEncoder(IoSession ioSession) {
                return (ProtocolEncoder) new CustomEncoder();
                }

        public ProtocolDecoder getDecoder(IoSession ioSession) {
                return (ProtocolDecoder) new CustomDecoder();
        }
}

Public class CustomDecoder extends CumulativeProtocolDecoder { /// Public 
Boolean doDecode(<args>) throws Exception {
        Try { 
                Int startPosition = ioBuffer.position();
                Boolean receivedEndSequence = false;
                
                StringBuffer buffer = new StringBuffer();
                while (ioBuffer.hasRemaining()) {
                        byte by = ioBuffer.get();
                        buffer.append((char)b);
                        if (buffer.toString().endWith(CodecFactory.EOM)) {
                                receivedEndSequence = true;
                        }
                }
                if (receivedEndSequence && ioBuffer.hasRemaining()) {
                        //logging
                        out.write(fullMessage);
                        return true;
                }
        }
        Catch (Exception e) {
                //logging
        }
}
}

public class CustomEncoder extends protocolEncoderAdapter {
        public void encode(<args>) {
                IoBuffer buf = IoBuffer.allocate(1, false);
                buf.setAutoExpand(true);
                buf.putString(CodecFactory.BOM);
                buf.putString(message.toString(), 
Charset.forName("ASCII").newEncoder());
                buf.putString(CodecFactory.EOM);
                buf.flip();
                out.write(buf);
        }
}

-----Original Message-----
From: Emmanuel Lécharny [mailto:[email protected]]
Sent: Monday, May 13, 2013 4:18 PM
To: [email protected]
Subject: Re: Help with NioSocketConnector

Le 5/13/13 8:45 PM, Whitener, Winona T. a écrit :
> Hello,
>
> I think that (pending more strenuous testing), I have found the problem.  I 
> have a portion of the written message that is "AAC".  When I change this to 
> "AAR" or "AAB" or just about any other combination of letter, I can get the 
> message through.  I don't know why "AAC" is the problem.  Are there other 
> abbreviations or strings that are problematic?
Nope. Again, there is something in your codec that should consider those 
strings as unexpected.

Nothing beats thourough unit testing :-)


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

Reply via email to