NACChannel ,TPDU and Header again!

235 views
Skip to first unread message

toy...@gmail.com

unread,
Jan 20, 2009, 5:08:35 AM1/20/09
to jPOS Users
hi,
server:
NACChannel clientSideChannel = new NACChannel
(new ISO87BPackager(), "6082360030".getBytes());
ThreadPool pool = new ThreadPool (5, 30);
pool.setLogger (logger, "iso-server-pool");
ISOServer server =
new ISOServer (
60000, clientSideChannel, pool);
client:
byte b[] = new byte[10];
NACChannel nc = new NACChannel("127.0.0.1",
60000,m.getPackager (),b);
((LogSource)nc).setLogger (logger, "test-channel");
ISOMUX mux = new ISOMUX(nc);
new Thread(mux).start();
ISOMsg response = mux.request(m, 60*1000);
byte bb []= response.getHeader();
if (response != null) {
response.dump(System.out, "");
}

result is:
<log realm="test-channel/127.0.0.1:60000" at="Tue Jan 20 05:07:22 ACT
2009.561">
<send>
<isomsg direction="outgoing">
<field id="0" value="0800"/>
</isomsg>
</send>
</log>
<log realm="test-channel/127.0.0.1:60000" at="Tue Jan 20 05:07:22 ACT
2009.561">
<receive>
<isomsg direction="incoming">
<header>00000000000000000000</header>
<field id="0" value="0801"/>
</isomsg>
</receive>
</log>

my question is why header do not contain 6082360030 but
00000000000000000000

thanks!

Alejandro Revilla

unread,
Jan 20, 2009, 7:09:20 AM1/20/09
to jpos-...@googlegroups.com
Hi,

"6082360030".getBytes() do not give you the bytes 6082360030, you want o
use ISOUtil.hex2byte ("6082360030").

Anyway, you'd save yourself a lot of time if you use Q2 and configure
your channels using XML. In addition, I'd strongly suggest to use QMUX.

On Tue, Jan 20, 2009 at 02:08:35AM -0800, toy...@gmail.com wrote:
>
> hi,
> server?$B!'
> NACChannel clientSideChannel = new NACChannel
> (new ISO87BPackager(), "6082360030".getBytes());
> ThreadPool pool = new ThreadPool (5, 30);
> pool.setLogger (logger, "iso-server-pool");
> ISOServer server =
> new ISOServer (
> 60000, clientSideChannel, pool);
> client?$B!'

toy...@gmail.com

unread,
Jan 20, 2009, 8:49:16 AM1/20/09
to jPOS Users
thanks Alejandro , can give me some example about QMUX?

toy...@gmail.com

unread,
Jan 20, 2009, 9:31:50 AM1/20/09
to jPOS Users
another question :
BASE1Header header = new BASE1Header("10.0.25.44","10.0.25.50");
header.setLen(5);
System.out.println("length:"+header.getLength
()); length:22
System.out.println
("ISOUtil.hexString"+ISOUtil.hexString(header.pack()));
ISOUtil.hexString160102001B10E0E210E0E20000000000000000000000
System.out.println("header.getSource
():"+header.getSource()); header.getSource():
10E0E2
System.out.println("header.getDestination
():"+header.getDestination()); header.getDestination():
10E0E2

1、why length is 22 what the usage of setLen()
2、why header.getSource() and header.getDestination() have the same
value

================================================================
BaseHeader baseheader = new BaseHeader();
baseheader.setDestination("10.0.25.44");
baseheader.setSource("10.0.25.50");
System.out.println("@@@@"+ISOUtil.hexString(baseheader.pack
()));

get Exception in thread "main" java.lang.NullPointerException errors?

Mark Salter

unread,
Jan 20, 2009, 9:58:06 AM1/20/09
to jpos-...@googlegroups.com
toy...@gmail.com wrote:
> another question :
> BASE1Header header = new BASE1Header("10.0.25.44","10.0.25.50");

Base1Header would be used in building messages to the VISA network. I'm
not sure you want to be using this class. The constructor does not
expect two ip addresses - it wants VISA station numbers (6 digits).


> header.setLen(5);
This sets the length field *within* this header.

> System.out.println("length:"+header.getLength
> ()); length:22
> System.out.println
> ("ISOUtil.hexString"+ISOUtil.hexString(header.pack()));
> ISOUtil.hexString160102001B10E0E210E0E20000000000000000000000

^^^^

This is where your length ended up (22+5) = x'001b'

> System.out.println("header.getSource
> ():"+header.getSource()); header.getSource():
> 10E0E2
> System.out.println("header.getDestination
> ():"+header.getDestination()); header.getDestination():
> 10E0E2
>
> 1、why length is 22 what the usage of setLen()

A Base1Header is (normally) 22 bytes long. The setLen set the length
(in the header) of the whole message - including the header bytes.

> 2、why header.getSource() and header.getDestination() have the same
> value

These are being set from the start of your ip address - which are too
long for VISA source and destination - which is expecting 6 numeric
digits. In each case it takes "10.0.2" and makes some BCD.

This is just not a class - I think - you should be using.

>
> ================================================================
> BaseHeader baseheader = new BaseHeader();
> baseheader.setDestination("10.0.25.44");
> baseheader.setSource("10.0.25.50");
> System.out.println("@@@@"+ISOUtil.hexString(baseheader.pack
> ()));
>
> get Exception in thread "main" java.lang.NullPointerException errors?

Where *exactly* is the Exception and can you give the full Exception
stacktrace? I imagine something is not being set and so is null at time
of pack, the line on which the Exception occurs will give us that detail.

--
Mark

David Bergert

unread,
Jan 20, 2009, 9:59:45 AM1/20/09
to jpos-...@googlegroups.com
> 1、why length is 22 what the usage of setLen()

because Base1Header is set to 22 ?

public class BASE1Header extends BaseHeader {

private static final long serialVersionUID = 6466427524726021374L;
public static final int LENGTH = 22;


setLen() sets field 3 in the Base1 Header

* 3 len[2]; Fld 4: Total Message Length 2B (Byte 3- 4)


> 2、why header.getSource() and header.getDestination() have the same
> value

Are you setting them ? or receiving a message that contains a Base1 Header
from VisaNet with these values set?


> ================================================================
> BaseHeader baseheader = new BaseHeader();
> baseheader.setDestination("10.0.25.44");
> baseheader.setSource("10.0.25.50");
> System.out.println("@@@@"+ISOUtil.hexString(baseheader.pack
> ()));
>
> get Exception in thread "main" java.lang.NullPointerException errors?
>


because the default constructor of BaseHeader() sets the header to null ?

public BaseHeader()
{
header = null;
}


David Bergert, CISSP, CISA, CPISM/A
www.paymentsystemsblog.com

>

Alejandro Revilla

unread,
Jan 20, 2009, 11:16:14 AM1/20/09
to jpos-...@googlegroups.com
Source and destination are not IP addresses. They are station IDs
provided by your acquirer.

Reply all
Reply to author
Forward
0 new messages