mina-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Whitener, Winona T." <Winona.White...@gd-ais.com>
Subject RE: Help with NioSocketConnector
Date Mon, 13 May 2013 21:05:38 GMT
And from the logs:

[CodeSource=AWT-EventQueue-0] Wrote the following to screen:  051320130444256623|127.0.0.1|0.0.0.0|AAR|21|AAR=1=9=1223546|b1f5b76614959922401b798e3098cf30
[CodeSource=NioProcessor-2] SENT: heapBuffer[pos=0 lim=0 cap=0: empty]
[CodeSource=NioProcessor-2] MinaclientHandler messageSent: 051320130444256623|127.0.0.1|0.0.0.0|AAR|21|AAR=1=9=1223546|b1f5b76614959922401b798e3098cf30
[CodeSource=NioProcessor-2] Wrote the following to the screen: Message sent: 051320130444256623|127.0.0.1|0.0.0.0|AAR|21|AAR=1=9=1223546|b1f5b76614959922401b798e3098cf30
[CodeSource=NioProcessor-2] CLOSED
[CodeSource=NioProcessor-2] CLOSED MINA Connection

As soon as that first message goes through, it closes the connection.  

The delimiter doesn't appear to matter--whether it is pipe or what.  The date at the front
seemed to matter at first, but doesn't appear to matter with further testing.  I thought "AAC"
was the issue, but apparently AAR is too.  Aar and aac in all lower case do not appear to
cause issues.  This is a standard message format for my program--the acceptor sends stuff
right on through without issue.  This is a shorter message than the acceptor's regular messages.

Is it possible that it is the location of that?  Maybe it's a regular place for the message
to be broken and so something is not getting carried across or something?



-----Original Message-----
From: Whitener, Winona T. [mailto:Winona.Whitener@gd-ais.com] 
Sent: Monday, May 13, 2013 4:50 PM
To: users@mina.apache.org
Subject: RE: Help with NioSocketConnector

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:Winona.Whitener@gd-ais.com] 
Sent: Monday, May 13, 2013 4:30 PM
To: users@mina.apache.org
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:elecharny@gmail.com]
Sent: Monday, May 13, 2013 4:18 PM
To: users@mina.apache.org
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 

Mime
View raw message