unpack error for MIP incoming message

157 views
Skip to first unread message

Alex

unread,
Sep 8, 2015, 10:50:59 AM9/8/15
to jPOS Users
Hi All,

I am newbie to JPOS and got stuck at connecting to Master card channel.

below is my server.xml, i have used NACChannel as the message header uses 2 byte message length and the packager as iso93ebcdic-custom.xml as the fields are in EBCDIC

<?xml version="1.0" encoding="UTF-8"?>

<server name="MRemote" class="org.jpos.q2.iso.QServer" logger="Q2">

<attr name="port" type="java.lang.Integer">6034</attr>

<attr name="maxSessions" type="java.lang.Integer">150</attr>

<channel

class="org.jpos.iso.channel.NACChannel" packager="org.jpos.iso.packager.GenericPackager"

logger="Q2">

<property name="packager-config" value="cfg\packager\iso93ebcdic-custom.xml"/>

</channel>

<request-listener class="org.jpos.q2.iso.TestMe4" logger="Q2">

<property name="my-property" value="ABC"/>

<property name="my-other-property" value="XYZ"/>

</request-listener>

</server>


when the Authorization systems sends an incoming message to the JPOS server, i am getting the following error.


<log realm="channel/xx.xx.xx.xx:xxxx" at="Tue Sep 08 21:28:04.735 CST 2015" lifespan="1170ms">

  <receive>

    <iso-exception>

      org.jpos.iso.IFE_NUMERIC: Problem unpacking field 5 (java.lang.ArrayIndexOutOfBoundsException: 74) unpacking field=5, consumed=65

      org.jpos.iso.ISOException: org.jpos.iso.IFE_NUMERIC: Problem unpacking field 5 (java.lang.ArrayIndexOutOfBoundsException: 74) unpacking field=5, consumed=65

                at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:275)

                at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:454)

                at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:965)

                at org.jpos.iso.BaseChannel.receive(BaseChannel.java:735)

                at org.jpos.iso.ISOServer$Session.run(ISOServer.java:156)

                at org.jpos.util.ThreadPool$PooledThread.run(ThreadPool.java:76)

    </iso-exception>

    --- data ---

    0000  F0 F8 F0 F0 C2 20 00 00  80 00 00 00 04 00 00 05  ..... ..........

0010  00 00 00 02 F0 F5 F0 F3  F7 F0 F7 F0 F9 F0 F8 F1  ................

0020  F3 F2 F8 F0 F4 F0 F3 F0  F9 F4 F7 F0 F6 F0 F0 F5  ................

0030  F9 F1 F3 F0 F6 F1 C3 C2  F0 40 40 40 40 F0 F0 F0  .........@@@@...

0040  F0 F0 F0 F0 F0 F0 F0 F2  F0 F0                    ..........


the message received is 0800 message, when i manually unpacked it there was no field 5. I believe the JPOS server is reading the header and bitmap wrongly.


below is the full message received from Authorization system.

004af0f8f0f0c2200000800000000400000500000002f0f5f0f3f7f0f7f0f9f0f8f1f0f0f9f3f7f0f3f0f2f1f4f0f6f0f0f5f9f1f3f0f6f1c3c2f040404040f0f0f0f0f0f0f0f0f0f0f2f0f0


First four digits is header followed by MTI and then bitmap.


Can you please suggest what channel and packager should i use ?


Thanks,

Alex

chhil

unread,
Sep 8, 2015, 11:33:53 AM9/8/15
to jpos-...@googlegroups.com
You may want to figure out if the channel is the right one.

NACChannel calculates the length as follows.

b[0][1] represent the length .

Based on your data your length is 148 (decimal).

b[0] = 148 mod 255 = 148 = 0x94
b[1] = 0 148 div 255 = 0x00

Naccchannel does the equivalent using bitwise operations.



Your dump indicates the the first 2 bytes of 004A. Which tricks the message into being 74 bytes long , so it only reads 74 instead of the 148 bytes.

Which is incidentally half the actual length (assuming I got my length calculations correct).
Which incidentally is also throwing an exception with an array index out of bounds at 74 as your channel hasn't read the full message.

I would recommend extending the NACChannel and changing the getMessageLength to multiply the value by 2.
I would also fix the sendMessageLength to divide by 2 based on the length that was calculated by the actual NACChannel.


-chhil





--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
 
Join us in IRC at http://webchat.freenode.net/?channels=jpos
 
You received this message because you are subscribed to the "jPOS Users" group.
Please see http://jpos.org/wiki/JPOS_Mailing_List_Readme_first
To post to this group, send email to jpos-...@googlegroups.com
To unsubscribe, send email to jpos-users+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jpos-users
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/f05428bc-2a84-4e62-87cb-f1fa12d78c9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

chhil

unread,
Sep 8, 2015, 11:36:38 AM9/8/15
to jpos-...@googlegroups.com

On Tue, Sep 8, 2015 at 9:03 PM, chhil <chi...@gmail.com> wrote:
b[0] = 148 mod 255 = 148 = 0x94
b[1] = 0 148 div 255 = 0x00

​Sorry, It should be 
b[1] = 148 mod 255 = 148 = 0x94
b[0] = 0 148 div 255 = 0x00

Alejandro Revilla

unread,
Sep 8, 2015, 2:05:15 PM9/8/15
to jPOS Users
Channel looks good, I'd try changing the bitmap field packager from IFE_BITMAP to IFB_BITMAP in the iso93ebcdic-custom.xml


chhil

unread,
Sep 9, 2015, 1:54:40 AM9/9/15
to jpos-...@googlegroups.com
Ignore my response, your channel is correct, I was counting the nibbles instead of the bytes.

-chhil

On Tue, Sep 8, 2015 at 9:03 PM, chhil <chi...@gmail.com> wrote:
Message has been deleted

Alex

unread,
Sep 9, 2015, 3:09:33 AM9/9/15
to jPOS Users
I tried changing the bitmap field to IFB_BITMAP and still getting error in unpacking.


<log realm="channel/xx.x.xx.xx:xxxx" at="Wed Sep 09 14:29:13.137 CST 2015" lifespan="8883ms">

  <receive>

    <iso-exception>

      org.jpos.iso.IFE_LLLBINARY: Problem unpacking field 0 (org.jpos.iso.ISOException: Field length 303 too long. Max: 256) unpacking field=55, consumed=36

      org.jpos.iso.ISOException: org.jpos.iso.IFE_LLLBINARY: Problem unpacking field 0 (org.jpos.iso.ISOException: Field length 303 too long. Max: 256) unpacking field=55, consumed=36

                at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:273)

                at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:454)

                at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:965)

                at org.jpos.iso.BaseChannel.receive(BaseChannel.java:735)

                at org.jpos.iso.ISOServer$Session.run(ISOServer.java:156)

                at org.jpos.util.ThreadPool$PooledThread.run(ThreadPool.java:76)

    </iso-exception>

    --- data ---

    0000  F0 F8 F0 F0 C2 20 00 00  80 00 00 00 04 00 00 05  ..... ..........

0010  00 00 00 02 F0 F5 F0 F3  F7 F0 F7 F0 F9 F0 F9 F0  ................

0020  F6 F2 F9 F1 F3 F0 F3 F7  F0 F5 F0 F0 F6 F0 F0 F5  ................

0030  F9 F1 F3 F0 F6 F1 C3 C2  F0 40 40 40 40 F0 F0 F0  .........@@@@...

0040  F0 F0 F0 F0 F0 F0 F0 F2  F0 F0                    ..........

 

  </receive>

Thanks,

Alex

iso93ebcdic-custom.xml

chhil

unread,
Sep 9, 2015, 8:50:32 AM9/9/15
to jpos-...@googlegroups.com

Get rid of the header

​ attribute​
in your packager definition.

<isopackager headerLength="9">

Then sort out your field definitions using a code snippet . If it throws an exception look at the output and the data to figure out what the definition should be. Its easier if you have a spec and fix the packager. You will need to sort this out yourself, by making changes to the packager since the readymade ones dont work for you.


        String inHex = "F0F8F0F0C22000008000000004000005" +
                "00000002F0F5F0F3F7F0F7F0F9F0F9F0" +
                "F6F2F9F1F3F0F3F7F0F5F0F0F6F0F0F5" +
                "F9F1F3F0F6F1C3C2F040404040F0F0F0" +
                "F0F0F0F0F0F0F0F2F0F0";

        GenericPackager pkgr;
        ISOMsg m = new ISOMsg();

        try {
            pkgr = new GenericPackager("path\\t
​o​
\\your\\iso93ebcdic-custom.xml"); Logger l = new Logger(); l.addListener(new SimpleLogListener()); pkgr.setLogger(l, ""); m.setPackager(pkgr); m.unpack(ISOUtil.hex2byte(inHex)); } catch (ISOException ex) { ex.printStackTrace(); m.dump(System.out, ""); }

-chhil


Alejandro Revilla

unread,
Sep 9, 2015, 1:16:01 PM9/9/15
to jPOS Users
Chhil, 'F0F8F0F0'
​ looks like a proper 0800 (in EBCDIC) to me, why do you skip 9 bytes?


chhil

unread,
Sep 9, 2015, 4:39:04 PM9/9/15
to jPOS Users

There is no header data present in the hexdump provided.

-chhil


Alejandro Revilla

unread,
Sep 9, 2015, 4:40:28 PM9/9/15
to jPOS Users
Sorry, didn't read the "get rid" part, thought you were suggesting to add a headerlength of 9. 



Alex

unread,
Sep 10, 2015, 9:42:30 AM9/10/15
to jPOS Users
thanks everyone, got this working. Removed the header line from the packager and JPOS started to read 0800 message.
Reply all
Reply to author
Forward
0 new messages