How is ISO8583 Header Derived and added to JPOS Message

1,441 views
Skip to first unread message

Abiodun Okusolubo

unread,
May 5, 2016, 3:16:54 PM5/5/16
to jPOS Users
Dear All,

I'm developing an ISO8583 Client that sends echo message using NACChannel.
The server received message is below (please note 2 byte header)

    Pid: 54132886 29/04/2016 18:58:31.838 Received 117 Bytes
    00 73 31 38 30 34 80 30 01 00 80 00 00 20 00 00 .s1804.0..... ..
    00 0c 00 00 00 20 30 30 30 30 30 30 30 30 30 30 ..... 0000000000
    30 30 32 30 31 36 30 34 32 39 31 36 32 31 35 31 0020160429162151
    38 33 31 30 34 31 31 37 30 30 32 35 30 30 30 30 8310411700250000
    30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
    30 30 30 30 30 31 31 30 30 30 30 30 33 32 39 33 0000011000003293
    38 32 31 31 32 32 32 32 32 33 30 34 39 33 38 30 8211222223049380
    30 33 43 4d 4e                                  03CMN


The response to that message is below (also note the 2 bytes header)

    Pid: 54132886 29/04/2016 18:58:31.843 Sent 111 Bytes
    00 00 31 38 31 34 80 30 00 00 02 00 00 20 00 00 ..1814.0..... ..
    00 0c 00 00 00 20 30 30 30 30 30 30 30 30 30 30 ..... 0000000000
    30 30 32 30 31 36 30 34 32 39 31 36 32 31 35 31 0020160429162151
    38 30 30 30 32 35 30 30 30 30 30 30 30 30 30 30 8000250000000000
    30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 31 0000000000000001
    31 30 30 30 30 30 33 32 39 33 38 32 31 31 32 32 1000003293821122
    32 32 32 33 30 34 39 33 38 43 4d 4e 20 20 20    222304938CMN

The response message always throws exception when i call channel.receive():

    <iso-exception>
          receive length 0 seems strange - maxPacketLength = 100000
          org.jpos.iso.ISOException: receive length 0 seems strange - maxPacketLength = 100000
        at org.jpos.iso.BaseChannel.receive(BaseChannel.java:663)
        at org.jpos.q2.iso.ChannelAdaptor$Receiver.run(ChannelAdaptor.java:295)
        at java.lang.Thread.run(Unknown Source)
    </iso-exception>

Given this scenario, I need to pack the message and send it without using JPOS channel
    byte[] requ=isoMsg.pack();
    DataOutputStream dataout = new DataOutputStream(socket.getOutputStream());
    DataInputStream datain = new DataInputStream(socket.getInputStream());
     dataout.flush();
     dataout.write(requ);

My Question is :
How is 2 Byte ISO8583 Header Derived and added to JPOS Message ?

Thanks.

Alejandro Revilla

unread,
May 5, 2016, 3:27:23 PM5/5/16
to jPOS Users

If you don’t need a two-byte length indicator, you can use PADChannel.




Abiodun Okusolubo

unread,
May 5, 2016, 7:38:32 PM5/5/16
to jPOS Users
Thanks Alejandro for your quick reply.
The server requires that the request message has two-byte header to get the message processed.
However NACChannel could successfully send a request message but could not process the response.

Therefore what is the value of "xxx" in the code below for MTI 1200.
isoMsg.setHeader("xxx".getBytes())

Cheers

chhil

unread,
May 5, 2016, 8:29:20 PM5/5/16
to jpos-...@googlegroups.com

The NACChannel expects a length header to be non zero. How will it gather bytes for the response if the response length header contains a length of 00 00?
Your server is not sending the correct header in the response.

-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/77f2db34-ab0f-4670-8cc7-64e438f45973%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abiodun Okusolubo

unread,
May 6, 2016, 12:46:21 AM5/6/16
to jPOS Users
Hello Chhil,
I totally agree the server is responding with header containing length 00 00, the OEM of banking solution have been quiet and I'm finding away
around it so that I can move on.

It would have been easier if I could read the entire response and skip the first 2 bytes. See example below

int responseLent = dataInputStream.read(response,0,response.length);
 byte [] printResponse = new byte[reslent-2];
 byte [] length = new byte[2];

 for(int i=0;i<responseLent;i++){
      if (i >= 2) {
          printResponse[i-2]=response[i];
      }else {
          length[i] = response[i];

chhil

unread,
May 6, 2016, 2:14:24 AM5/6/16
to jpos-...@googlegroups.com

There is a reason why length headers are important. You could get 2 message responses at the tcp packet level following each other and you would incorrectly gather the 2 responses as one reading all the data in the stream. 
How many bytes would you read to determine the message is complete?
I don't think it's reasonable to hack your way through to implement something that is clearly a problem at the server side.

If you still really want to do this. In your overriden receive method  read the first 2 bytes and discard, them do what the padchannel does in its receive method.

-chhil

Reply all
Reply to author
Forward
0 new messages