NACChannel TPD swap not working

51 views
Skip to first unread message

jayadeep.cse

unread,
Dec 21, 2016, 6:55:51 AM12/21/16
to jPOS Users
Hi All,

Below is my 10_server_simulator.xml  chennel specification file -
 
<channel name="MMSChannel" class="org.jpos.iso.channel.NACChannel" logger="Q2" realm="NETSChannel" packager="org.jpos.iso.packager.GenericPackager" header="xxxxxxxxxx">
        <property name="packager-config" value="iso87ascii.xml" />
        <property name="packager-logger" value="Q2"/>
</channel>


I am using QServer and GenericPackager. 
 The problem I am facing is TPDU is not getting swapped for response message. Even I have tried doing it manually. Got the header from request, swapped the bytes and assigned the header to the response. But still it is not getting swapped.

Any inputs on this please.


Thanks,
Jayadeep

chhil

unread,
Dec 21, 2016, 7:49:31 AM12/21/16
to jpos-...@googlegroups.com


The NACChannel the tpdu to be a header of width 5. It only swaps it then.
What is your header configured as in the channel definition?
Maybe try stepping through the NACChannel code to see why its not swapping?

You can take a look at the the sendMessageHeader of the NACChannel here.

-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
---
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+unsubscribe@googlegroups.com.
To post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/659014e4-abfe-4707-895b-0e613c77f501%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jayadeep.cse

unread,
Dec 21, 2016, 11:40:39 AM12/21/16
to jPOS Users
Thanks a lot Chhil. It seems to me, its because of length more than 5 byte TPDU is not getting swapped. I will look into this.

Thanks a ton.

Jayadeep

jayadeep.cse

unread,
Dec 22, 2016, 4:54:56 AM12/22/16
to jPOS Users
Hi Chill,

Thanks a lot for your help. The length was of 5 bytes always but somehow the sendMessageHeader was not getting invoked causing this issue. 
I instantiated the response message by cloning the request message and it is working now. 

Thanks,
Jayadeep


On Wednesday, December 21, 2016 at 7:55:51 PM UTC+8, jayadeep.cse wrote:

chhil

unread,
Dec 22, 2016, 5:23:42 AM12/22/16
to jpos-...@googlegroups.com
Glad to hear its working. I think the sendMessageHeader always gets called from the basechannel, so there is still something wrong, you shouldnt have to do anything by hand.


I have been using this example all morning another thread. 

The client sends a message using NACChannel, and uses tpdu of 0x0 0x1 0x2 0x3 0x4 
The server responds back and you can see the header/tpdu with bits swapped in the server send and visible also in the clients receive.
Nothing additional had to be done.

import java.io.IOException;

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.ISOUtil;
import org.jpos.iso.channel.NACChannel;
import org.jpos.iso.packager.ISO87APackager;
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 ISOException, IOException {

        Logger l = new Logger();
        l.addListener(new SimpleLogListener());
        NACChannel sc = new NACChannel(new ISO87APackager(), new byte[] { 5, 6, 7, 8, 9 });

        sc.setLogger(l, "serverchannel");
        ISOServer server = new ISOServer(7776, sc, new ThreadPool(10, 100));
        server.setLogger(l, "server");
        server.addISORequestListener(new ISORequestListener() {

            @Override
            public boolean process(ISOSource source, ISOMsg m) {

                System.out.println(ISOUtil.hexdump(m.getHeader()));
                try {
                    m.dump(System.out, ">>");
                    m.setResponseMTI();
                    source.send(m);
                }
                catch (ISOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                return true;
            }
        });
        Thread t = new Thread(server);
        t.start();
        NACChannel cs = new NACChannel("127.0.0.1", 7776, new ISO87APackager(), new byte[] { 0, 1, 2, 3, 4 });
        cs.setLogger(l, "clientchannel");
        ISOMsg m = new ISOMsg();
        m.setMTI("0200");
        m.set(2, "123456789");

        cs.connect();
        cs.send(m);
        cs.receive();
    }
}


output

<log realm="server" at="Thu Dec 22 15:47:53 IST 2016.283" lifespan="57ms">
  <iso-server>
    listening on port 7776
  </iso-server>
</log>
<log realm="clientchannel/127.0.0.1:7776" at="Thu Dec 22 15:47:53 IST 2016.305" lifespan="82ms">
  <connect>
    127.0.0.1:7776
  </connect>
</log>
<log realm="clientchannel/127.0.0.1:7776" at="Thu Dec 22 15:47:53 IST 2016.309" lifespan="3ms">
  <send>
    <isomsg direction="outgoing">
      <!-- org.jpos.iso.packager.ISO87APackager -->
      <field id="0" value="0200"/>
      <field id="bitmap" value="{2}" type="bitmap"/>
      <field id="2" value="123456789"/>
    </isomsg>
  </send>
</log>
<log realm="serverchannel/127.0.0.1:40262" at="Thu Dec 22 15:47:53 IST 2016.314" lifespan="2ms">
  <receive>
    <isomsg direction="incoming">
      <!-- org.jpos.iso.packager.ISO87APackager -->
      <header>0001020304</header>
      <field id="0" value="0200"/>
      <field id="bitmap" value="{2}" type="bitmap"/>
      <field id="2" value="123456789"/>
    </isomsg>
  </receive>
</log>

>><isomsg direction="incoming">
>>  <!-- org.jpos.iso.packager.ISO87APackager -->
>>  <header>0001020304</header>
>>  <field id="0" value="0200"/>
>>  <field id="bitmap" value="{2}" type="bitmap"/>
>>  <field id="2" value="123456789"/>
>></isomsg>
<log realm="serverchannel/127.0.0.1:40262" at="Thu Dec 22 15:47:53 IST 2016.315">
  <send>
    <isomsg direction="outgoing">
      <!-- org.jpos.iso.packager.ISO87APackager -->
      <header>0003040102</header>
      <field id="0" value="0210"/>
      <field id="bitmap" value="{2}" type="bitmap"/>
      <field id="2" value="123456789"/>
    </isomsg>
  </send>
</log>
<log realm="clientchannel/127.0.0.1:7776" at="Thu Dec 22 15:47:53 IST 2016.316" lifespan="6ms">
  <receive>
    <isomsg direction="incoming">
      <!-- org.jpos.iso.packager.ISO87APackager -->
      <header>0003040102</header>
      <field id="0" value="0210"/>
      <field id="bitmap" value="{2}" type="bitmap"/>
      <field id="2" value="123456789"/>
    </isomsg>
  </receive>
</log>



--
--
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
---
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+unsubscribe@googlegroups.com.
To post to this group, send email to jpos-...@googlegroups.com.

jayadeep.cse

unread,
Dec 22, 2016, 8:43:07 PM12/22/16
to jPOS Users
I see. May be I need to dig out more to find out the root cause that I will.

Thanks,
Jayadeep

On Wednesday, December 21, 2016 at 7:55:51 PM UTC+8, jayadeep.cse wrote:

Andrés Alcarraz

unread,
Dec 27, 2016, 6:50:16 PM12/27/16
to jpos-...@googlegroups.com

Hi Jayadeep, it would be helpful to see your server simulator setup including your bsh script, maybe you are missing the header when you create the response, how are you building it?

Haw are you sure the sendMessageHeader is not being called at all? It is somehow impossinbe since it is in the path of the send method.

Best regards and happy holidays for all jpos-users group.


Andrés.



El 22/12/16 a las 22:43, jayadeep.cse escribió:
--
--
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
---
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 post to this group, send email to jpos-...@googlegroups.com.

jayadeep.cse

unread,
Dec 27, 2016, 8:19:31 PM12/27/16
to jPOS Users
Hi Andrés,


Yes the header was missing when I create the response message causing this issue.

Thanks,
Jayadep


On Wednesday, December 21, 2016 at 7:55:51 PM UTC+8, jayadeep.cse wrote:
Reply all
Reply to author
Forward
0 new messages