Unable to unpack the 1804 request sent from switch

65 views
Skip to first unread message

DPR

unread,
Jul 16, 2016, 1:27:00 PM7/16/16
to jPOS Users
Hi,

I am unable to unpack the 1804 request sent from the switch. I have pasted the hexadump of the request I am receiving. The below data is test data. Please help.

header = 49534F3730313030303030
Exception in thread "main" org.jpos.iso.ISOException: org.jpos.iso.IFA_NUMERIC: Problem unpacking field 28 (java.lang.RuntimeException: Required 6 but just got 2 bytes) unpacking field=28, consumed=81
at com.XXXPackager.unpack(MOROCCOPackager.java:640)
at com.XXX1804HttpRequest.main(XXX1804HttpRequest.java:70)


  <info>
    Hexa value of response :- 49534F373031303030303031383034023001808800000031363037313631373035383838343032313630373136313730353439383033303030303036313031303130363139383137383838343032
  </info>
</log>
<log realm="XXXChannel" at="Sat Jul 16 22:34:58 IST 2016.723">
  <info>
    Hexa dump of response :- 0000  49 53 4F 37 30 31 30 30  30 30 30 31 38 30 34 02  ISO701000001804.
0010  30 01 80 88 00 00 00 31  36 30 37 31 36 31 37 30  0......160716170
0020  35 38 38 38 34 30 32 31  36 30 37 31 36 31 37 30  5888402160716170
0030  35 34 39 38 30 33 30 30  30 30 30 36 31 30 31 30  5498030000061010
0040  31 30 36 31 39 38 31 37  38 38 38 34 30 32        10619817888402

  </info>
</log>
<log realm="XXXChannel" at="Sat Jul 16 22:34:58 IST 2016.723">
  <info>
    Inside XXXChannel.getDynamicPackager() line #322-->
  </info>
</log>
<log realm="channel/xxxx" at="Sat Jul 16 22:34:58 IST 2016.765" lifespan="601015ms">
  <receive>
    <isomsg direction="incoming">
      <!-- com.XXXXPackager[iso93asciiB-custom.xml] -->
      <header>49534F373031303030303031383034</header>
      <field id="0" value="1804"/>
      <field id="7" value="1607161705"/>
      <field id="11" value="888402"/>
      <field id="12" value="160716170549"/>
      <field id="24" value="803"/>
      <field id="25" value="0000"/>
      <field id="33" value="101010"/>
      <field id="37" value="619817888402"/>
    </isomsg>
  </receive>

Please find the attached xml.

Regards,
DPR
iso93asciiB-custom.xml

DPR

unread,
Jul 16, 2016, 9:58:42 PM7/16/16
to jPOS Users
Hi,

I want to explain clearly what I am trying to achieve, here is the flow of my application. First I send 1804 (network authorization request) to switch, then the switch responds with 1814 response and again the switch will send back 1804 request for exchanging keys and I need to send back 1814 response. 
First iteration of sending 1804 and receiving 1814 is working fine. But the next key exchange process where the switch will send 1804, I am not able to handle that request and reply with 1814. Please suggest me some sample code where we can do this kind of transaction. 
My jPOS application is receiving the second 1804 request but is not able to send back the same to my application to handle it. Please help.

Best Regards,
DPR

chhil

unread,
Jul 16, 2016, 11:56:14 PM7/16/16
to jpos-...@googlegroups.com
If you turn packager logging on, and unpack the hexdump, you will notice that field 28 is not even present in message. 
Much like the field 35 that was not present in an earlier thread of yours. Since the ISOMsg can unpack it fine standalone, 
means that your channel is still doing something to the message by separating the header from the message bytes incorrectly 
causing the bitmap to get skewed. You continue doing things the old way and expects results to change, 
I wish I could write code based on optimism :)

-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/11feabf3-d655-4f0f-830e-b7fcfcebd6d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

chhil

unread,
Jul 17, 2016, 3:11:00 AM7/17/16
to jpos-...@googlegroups.com

Another attempt to assist you.
Remove the header attribute from your packager xml.
Add the header to your client channel adapter deploy.
Use the AsciiChannel provided by jpos (based on how you are treating the length prepended to the channel).

Code Sample:
Creates a server to listen for connections.
Creates a client and connects.
Server sends a request message.
Client receives the request message.
Client Responds to the request.
Server receives the request.
No Exceptions.
If you compare the hexdumps you will see identical data, which according me to indicates, your custom channel aka hack is not required.

import java.io.IOException;

import org.jpos.iso.ISOChannel;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISORequestListener;
import org.jpos.iso.ISOServer;
import org.jpos.iso.ISOSource;
import org.jpos.iso.ServerChannel;
import org.jpos.iso.channel.ASCIIChannel;
import org.jpos.iso.packager.GenericPackager;
import org.jpos.util.Logger;
import org.jpos.util.SimpleLogListener;
import org.jpos.util.ThreadPool;

public class Test {

    public static void main(String[] args) throws IOException, ISOException {

        Logger l = new Logger();
        l.addListener(new SimpleLogListener());
        GenericPackager serverPkg = new GenericPackager(
                "C:\\temp\\iso93asciiB-custom.xml");
        serverPkg.setLogger(l, "Server"); // So that the output can be differentiated based on realm

        GenericPackager clientPkg = new GenericPackager(
                "C:\\temp\\iso93asciiB-custom.xml");
        clientPkg.setLogger(l, "Client");// So that the output can be differentiated based on realm
        // Simulate a server and listen on a port
        ISOChannel serverChannel = new ASCIIChannel(serverPkg);
        ((ASCIIChannel) serverChannel).setHeader("ISO70100000");
        // AN equivalent in your channel adaptor deploy file would be
        // <channel class="org.jpos.iso.channel.ASCIIChannel"
        // packager="org.jpos.iso.packager.GenericPackager"
        // header="ISO70100000"> .....
        // This is evident from the ChanelAdaptor code
        // QFactory.invoke (channel, "setHeader", e.getAttributeValue ("header"));
        ((ASCIIChannel) serverChannel).setLogger(l, "server");
        ISOServer server = new ISOServer(7654, (ServerChannel) serverChannel,
                new ThreadPool(10, 100, "serverListeningThread"));

        server.addISORequestListener(new ISORequestListener() {
            // If the client sends a message, the server will respond with and approval if its a request message
            @Override
            public boolean process(ISOSource source, ISOMsg msg) {
                try {
                    if (!msg.isRequest()) {
                        msg.setResponseMTI();
                        msg.set(39, "000");
                        source.send(msg);
                    }
                }
                catch (ISOException | IOException ex) {

                }

                return true;
            }
        });
        Thread serverThread = new Thread(server);
        serverThread.start(); // beyond this point the server is listening for a client connection

        ASCIIChannel clientChannel = new ASCIIChannel("127.0.0.1", 7654, clientPkg);
        clientChannel.setHeader("ISO70100000");
​ //Similar to server, you can configure the constant in your deploy file​
clientChannel.setLogger(l, "client"); clientChannel.connect(); // connect to server, it will be seen in the output console ISOChannel connectChannel = server.getLastConnectedISOChannel();// Since server can have multiple connections, // we get the last one that connected to it. ISOMsg serverInitiatedRequest = new ISOMsg(); serverInitiatedRequest.set(0, "1804"); serverInitiatedRequest.set(7, "1607161705"); serverInitiatedRequest.set(11, "888402"); serverInitiatedRequest.set(12, "160716170549"); serverInitiatedRequest.set(24, "803"); serverInitiatedRequest.set(25, "0000"); serverInitiatedRequest.set(33, "101010"); serverInitiatedRequest.set(37, "619817888402"); connectChannel.send(serverInitiatedRequest); // use the last one connected to send a request message to the client. ISOMsg receivedRequest = clientChannel.receive();// receive the serers request message at the client ISOMsg clientResponse = (ISOMsg) receivedRequest.clone(); clientResponse.setResponseMTI(); clientResponse.set(39, "000"); clientChannel.send(clientResponse); // send the response to server } }

Output

<log realm="client/127.0.0.1:7654" at="Sun Jul 17 12:31:55 IST 2016.764" lifespan="33ms">
  <connect>
    127.0.0.1:7654
  </connect>
</log>
<log realm="Server" at="Sun Jul 17 12:31:55 IST 2016.784" lifespan="4ms">
  <pack>
    31383034023001808800000031363037313631373035383838343032313630373136313730353439383033303030303036313031303130363139383137383838343032
  </pack>
</log>
<log realm="server/127.0.0.1:10614" at="Sun Jul 17 12:31:55 IST 2016.785" lifespan="7ms">
  <send>
    <isomsg direction="outgoing">
      <!-- org.jpos.iso.packager.GenericPackager[C:\temp\iso93asciiB-custom.xml] -->
      <field id="0" value="1804"/>
      <field id="7" value="1607161705"/>
      <field id="11" value="888402"/>
      <field id="12" value="160716170549"/>
      <field id="24" value="803"/>
      <field id="25" value="0000"/>
      <field id="33" value="101010"/>
      <field id="37" value="619817888402"/>
    </isomsg>
  </send>
</log>
<log realm="Client" at="Sun Jul 17 12:31:55 IST 2016.787" lifespan="1ms">
  <unpack>
    31383034023001808800000031363037313631373035383838343032313630373136313730353439383033303030303036313031303130363139383137383838343032
    <bitmap>{7, 11, 12, 24, 25, 33, 37}</bitmap>
    <unpack fld="7" packager="org.jpos.iso.IFA_NUMERIC">
      <value>1607161705</value>
    </unpack>
    <unpack fld="11" packager="org.jpos.iso.IFA_NUMERIC">
      <value>888402</value>
    </unpack>
    <unpack fld="12" packager="org.jpos.iso.IFA_NUMERIC">
      <value>160716170549</value>
    </unpack>
    <unpack fld="24" packager="org.jpos.iso.IFA_NUMERIC">
      <value>803</value>
    </unpack>
    <unpack fld="25" packager="org.jpos.iso.IFA_NUMERIC">
      <value>0000</value>
    </unpack>
    <unpack fld="33" packager="org.jpos.iso.IFA_LLNUM">
      <value>101010</value>
    </unpack>
    <unpack fld="37" packager="org.jpos.iso.IF_CHAR">
      <value>619817888402</value>
    </unpack>
  </unpack>
</log>
<log realm="client/127.0.0.1:7654" at="Sun Jul 17 12:31:55 IST 2016.789" lifespan="4ms">
  <receive>
    <isomsg direction="incoming">
      <!-- org.jpos.iso.packager.GenericPackager[C:\temp\iso93asciiB-custom.xml] -->
      <header>49534F3730313030303030</header>
      <field id="0" value="1804"/>
      <field id="7" value="1607161705"/>
      <field id="11" value="888402"/>
      <field id="12" value="160716170549"/>
      <field id="24" value="803"/>
      <field id="25" value="0000"/>
      <field id="33" value="101010"/>
      <field id="37" value="619817888402"/>
    </isomsg>
  </receive>
</log>
<log realm="Client" at="Sun Jul 17 12:31:55 IST 2016.791">
  <pack>
    31383134023001808A00000031363037313631373035383838343032313630373136313730353439383033303030303036313031303130363139383137383838343032303030
  </pack>
</log>
<log realm="Server" at="Sun Jul 17 12:31:55 IST 2016.791">
  <unpack>
    31383134023001808A00000031363037313631373035383838343032313630373136313730353439383033303030303036313031303130363139383137383838343032303030
    <bitmap>{7, 11, 12, 24, 25, 33, 37, 39}</bitmap>
    <unpack fld="7" packager="org.jpos.iso.IFA_NUMERIC">
      <value>1607161705</value>
    </unpack>
    <unpack fld="11" packager="org.jpos.iso.IFA_NUMERIC">
      <value>888402</value>
    </unpack>
    <unpack fld="12" packager="org.jpos.iso.IFA_NUMERIC">
      <value>160716170549</value>
    </unpack>
    <unpack fld="24" packager="org.jpos.iso.IFA_NUMERIC">
      <value>803</value>
    </unpack>
    <unpack fld="25" packager="org.jpos.iso.IFA_NUMERIC">
      <value>0000</value>
    </unpack>
    <unpack fld="33" packager="org.jpos.iso.IFA_LLNUM">
      <value>101010</value>
    </unpack>
    <unpack fld="37" packager="org.jpos.iso.IF_CHAR">
      <value>619817888402</value>
    </unpack>
    <unpack fld="39" packager="org.jpos.iso.IFA_NUMERIC">
      <value>000</value>
    </unpack>
  </unpack>
</log>
<log realm="server/127.0.0.1:10614" at="Sun Jul 17 12:31:55 IST 2016.792" lifespan="26ms">
  <receive>
    <isomsg direction="incoming">
      <!-- org.jpos.iso.packager.GenericPackager[C:\temp\iso93asciiB-custom.xml] -->
      <header>49534F3730313030303030</header>
      <field id="0" value="1814"/>
      <field id="7" value="1607161705"/>
      <field id="11" value="888402"/>
      <field id="12" value="160716170549"/>
      <field id="24" value="803"/>
      <field id="25" value="0000"/>
      <field id="33" value="101010"/>
      <field id="37" value="619817888402"/>
      <field id="39" value="000"/>
    </isomsg>
  </receive>
</log>
<log realm="client/127.0.0.1:7654" at="Sun Jul 17 12:31:55 IST 2016.793" lifespan="3ms">
  <send>
    <isomsg direction="outgoing">
      <!-- org.jpos.iso.packager.GenericPackager[C:\temp\iso93asciiB-custom.xml] -->
      <header>49534F3730313030303030</header>
      <field id="0" value="1814"/>
      <field id="7" value="1607161705"/>
      <field id="11" value="888402"/>
      <field id="12" value="160716170549"/>
      <field id="24" value="803"/>
      <field id="25" value="0000"/>
      <field id="33" value="101010"/>
      <field id="37" value="619817888402"/>
      <field id="39" value="000"/>
    </isomsg>
  </send>
</log>
​-chhil​

Mark Salter

unread,
Jul 17, 2016, 5:05:58 AM7/17/16
to jpos-...@googlegroups.com
On 16/07/16 18:26, DPR wrote:
>
> I am unable to unpack the 1804 request sent from the switch.
Have you found and read and understood the specification for the
interface you want to deal with yet?

Although Chill is tying to help, I honestly think you should do some
'work' first.

Think of the things *we* don't know.

All we really have is your attempts and a hex dump.

Please do your leg work first and when you actually have trouble come
back with a smart question.

"Please help" yourself first, or pay someone to do the work you don;t
seem to be bothered to do :-)

--
Mark

DPR

unread,
Jul 19, 2016, 4:49:53 AM7/19/16
to jPOS Users
Hi Chhil, 


Thank you for your valuable suggestion. I forgot to mention that I have been trying to implement the solution in number of ways, but none of them worked. So, I have posted here in the forum.

I have the web application "A", from where I try to initiate 1804 request, this hits the gatewayserver (xxx.xxx.xxx.xx/ xxxx). We have deployed the jPOS tgz on the gatewayserver, inside the jPOS application (channel- adapter), i mention the ip address/port (yyy.yyy.yyyy.yy/yyyy) of the switch to which it has to connect. we are getting two responses from the switch (1814 and 1804). for the 1804 that I receive, I should be able to reply with response.But I could not achieve this.

To tell all my attempts to do it, I have modified the code in application "A" .

if(respMti !=null && respMti.equals("1804")){
HttpClient clientTwo = HttpClients.createDefault();
   HttpPost postRequestTwo = new HttpPost("http://xxx.xxx.xxx.xx:xxxx/abc");
   ByteArrayEntity entityTwo = new ByteArrayEntity(formMessageTwo());
postRequestTwo.setEntity(entityTwo);
try {
HttpResponse responseTwo =  clientTwo.execute(postRequestTwo);
if(responseTwo==null){
System.out.println("Successfully sent 1814 response and no further request from switch is received");
}else{
System.out.println("Further request from switch is received. Please check with switch");
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

And  the jPOS application is deployed on gateway, is started by a shell script. 

My attempt to modify application "A", did not work. So, I tried modifying the channel class in the jPOS application, but even that did not work. 
I checked the sample you sent, I am not able to run it as a standalone java application, as I cannot connect to the switch directly from the standalone java app. 

If I send 1804 request to switch, I receive 1814 from switch -> jPOS -> application "A".  And we are able to use the response in application "A". 
this way we get the response from the jPOS to web application. 

HttpResponse responseTwo =  clientTwo.execute(postRequestTwo);

In the second request from switch,  switch sends 1804 request to jPOS. But for that request, my custom channel has to be modified to handle it.How should I modify the jPOS application such that it receives the  1804 response and it should send  back the 1814.

Hope I am clear. I am trying to give more explanation, so you can tell me what to do exactly.Please let me know if you need any further information

Regards,
DPR


On Saturday, July 16, 2016 at 10:57:00 PM UTC+5:30, DPR wrote:

Mark Salter

unread,
Jul 19, 2016, 6:47:19 AM7/19/16
to jPOS Users
On Tuesday, July 19, 2016 at 9:49:53 AM UTC+1, DPR wrote:
I have the web application "A", from where I try to initiate 1804 request, this hits the gatewayserver (xxx.xxx.xxx.xx/ xxxx). We have deployed the jPOS tgz on the gatewayserver, inside the jPOS application (channel- adapter), i mention the ip address/port (yyy.yyy.yyyy.yy/yyyy) of the switch to which it has to connect. we are getting two responses from the switch (1814 and 1804). for the 1804 that I receive, I should be able to reply with response.But I could not achieve this.

There appear to be some gaps in your understanding here - I guess you still have not acquired and read the documentation describing the interface's expectation of your client system/connection?


To tell all my attempts to do it, I have modified the code in application "A" .

if(respMti !=null && respMti.equals("1804")){
HttpClient clientTwo = HttpClients.createDefault();
   HttpPost postRequestTwo = new HttpPost("http://xxx.xxx.xxx.xx:xxxx/abc");
   ByteArrayEntity entityTwo = new ByteArrayEntity(formMessageTwo());
postRequestTwo.setEntity(entityTwo);
try {
HttpResponse responseTwo =  clientTwo.execute(postRequestTwo);
if(responseTwo==null){
System.out.println("Successfully sent 1814 response and no further request from switch is received");
}else{
System.out.println("Further request from switch is received. Please check with switch");
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

This sort of approach is doomed to failure, attempting to 'sequentially' handle sign-on requests and generating response all sequentially and in advance of sending the request that I suspect you really want to is just unlikely to happen consistently.

Additionally you would never really want to establish a session per request - that makes no sense for your clients or for the target system.

Perhaps there is a document describing the interface you are connecting to - I wonder if you have anything yet?
 

If I send 1804 request to switch, I receive 1814 from switch -> jPOS -> application "A".  And we are able to use the response in application "A". 
this way we get the response from the jPOS to web application. 

Lost me, but never mind.

I suspect that the server you are connecting to expects to be able to exchange sign-ons at random and when needed - in both directions, so you must separate these exchanges from your request exchange.

I suspect there is a document describing this need - I wonder if you have it just yet?


In the second request from switch,  switch sends 1804 request to jPOS. But for that request, my custom channel has to be modified to handle it.How should I modify the jPOS application such that it receives the  1804 response and it should send  back the 1814.

Hope I am clear. I am trying to give more explanation, so you can tell me what to do exactly.Please let me know if you need any further information

We are having to guess what your target system needs - I am sure you grasped that from my repeated reference to the documentation you should have requested and read by now.

So to try and summerise...

From a webserver based processing in which you are trying to :-

- establish a session with an ISO8583 server by sending an 1804 request  (and getting an 1814 response)
- then send in the ISO request, likely formed from a web service request you receive.

BUT the server you are connecting with is also sending your connection an 1804 *request* to which you are required to respond - perhaps with some security information/identification?

You need to separate out the components, not try to do everything in one hit as you seem to be trying to;  conforming with the target systems interface specification is part of that need.

Your jpos application should be signing on to the target independently and handling any sign-on exchanges in either direction - to conform with what I expect to be in that document I am tired of mentioning sets out.
.
Your jpos setup can provide a MUX to use for your request, whilst maintaining the connection in a dedicated thread/channel.

The good news is that this is all possible - easily, you just need to form the correct approach and form the correct jpos components and setup.

The bad news is that you really are going to have to ask for the target interface specification so you know what you need to do and how;  I think I have mentioned that fact before :-)

--
Mark

chhil

unread,
Jul 19, 2016, 8:38:41 AM7/19/16
to jpos-...@googlegroups.com
So you send a 1804 the switch responds with a 1814 and you can handle that, but when the switch sends a 1804 you can't handle it.

There are a few possibilities here :
1. The 1804 from the switch has a field that you cannot handle and maybe its field level packager is wrong.
2. Your customized packager/Channel java class is not handling it.
3. The switch initiated requests are not sending correct data.

One of the things you need remove from your custom XXXXXChannel.java is 
XXXXFinalPackager packager;

You need to use the packager member variable from the base class. Sorry I don't have the time or patience to debug your custom channels and packagers, 
especially since they are not needed and causing more problems.

-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.
Reply all
Reply to author
Forward
0 new messages