My ISO JPOS client implementation prints message length output correctly but when I do tcpdump i see the message length prefixed with "1". So the tcpdump shows the message header as "10000431804003001000000000084946520200922160158801"
instead of "0000431804003001000000000084946520200922160158801"
Any idea what could be the issue.
Below is my client print out of the message length and the unpack ISO:
0000431804003001000000000084946520200922160158801
<log realm="post-channel/xx.xx.xx.x:xxxx" at="Tue Sep 22 16:01:58 WAT 2020.579" lifespan="1ms">
<send>
<isomsg direction="outgoing">
<!-- org.jpos.iso.packager.GenericPackager[deploy/cfg/customizedPackager.xml] -->
<header>303030303433</header>
<field id="0" value="1804"/>
<field id="11" value="849465"/>
<field id="12" value="20200922160158"/>
<field id="24" value="801"/>
</isomsg>
</send>
</log>
my code implementation below:
Date currDate = new Date();
SimpleDateFormat lda = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault());
String d = lda.format(currDate);
QMUX mux1 = (QMUX) NameRegistrar.getIfExists("mux.pesa-link-mux");
LoggingUtil.logDebugInfo("SIGNON MUX: " + mux1.getName());
Random randomGenerator = new Random();
int randomInt = randomGenerator.nextInt(1000000);
String formatedInt;
formatedInt = String.format("%06d", randomInt);
ISOMsg m = new ISOMsg();
//m.setHeader("000043".getBytes());
ISOPackager p = new GenericPackager("/usr/app/customized.xml");
byte[] b = new byte[1];
m.setPackager(p);
m.setMTI("1804");
m.set(11, formatedInt);
m.set(12, d);
m.set(24, "801");
byte[] data = m.pack();
short messageLength = (short) data.length;
String msglen = String.format("%6s", String.valueOf(messageLength)).replace(' ', '0');
String message = msglen + new String(data);
LoggingUtil.logDebugInfo(":: message length :: " + message + " :: len: " + msglen);
ISOMsg resp = mux1.request(m, 30 * 1000);
channel config here
<channel-adaptor name="pd-channel-adaptor" class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class="org.jpos.iso.channel.PostChannel" type="client" connect="yes" logger="Q2"
realm="post-channel" packager="org.jpos.iso.packager.GenericPackager">
<property name="packager-config" value="deploy/cfg/customized.xml" />
<property name="host" value="1111.11.11.11" />
<property name="port" value="3322" />
</channel>
<in>pd_link_send</in>
<out>pd_link_receive</out>
<reconnect-delay>1000</reconnect-delay>
<keep-alive>yes</keep-alive>
</channel-adaptor>
It seems your server is expecting the length as 6 ASCII digits, so you need to use
ASCIIChannel
with propertylength-digits
set to6
And you don't have to put the length in the header.