import java.io.IOException;
import org.jpos.iso.ClientChannel;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.channel.ASCIIChannel;
import org.jpos.iso.packager.ISO87APackager;
public class Test {
public static void main(String[] args) throws ISOException, IOException {
ClientChannel cs = new ASCIIChannel("127.0.0.1", 7666, new ISO87APackager());
ISOMsg m = new ISOMsg();
m.setMTI("0200");
m.set(2, "123456789");
cs.connect(); // make sure netcat server is already running
cs.send(m);
}
}
C:\>ncat -l 7666
00310200400000000000000009123456789
--
--
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/bf2f260a-172c-45ff-946c-d767899ebda0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi PK, interpreting what you are saying problem is that the client is not sending as lenght what you are expecting ?
It's really difficult to help givn the lack of information, an hexdump with the stream your client is sending would be helpful. The most probably thing is that your channel is not aligned with your client.
Best regards
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/d5881eed-9c3a-4cbc-98d7-cbc548aa8d88%40googlegroups.com.
I have build a demo server using ASCIIChannel & ISO87APackager and this server not getting length as prefix from client.
Sorry to say that does not clarify enough, please share your server and client code. If you are using same channel and same packager, there is no way that you receive something different from what you send. ASCIIChannel and ISO87APackager are widely tested and used everwhere.
Pleas as Mark suggested ask a smart question
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/91fb2ddc-2cfe-425d-8531-3c64b2b5e8af%40googlegroups.com.
Your problem is that you are sending a message with a header but on the server you are not configuring the channel to expect that header.
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/397f5b4b-3092-40f1-8306-8cd34ef79a4d%40googlegroups.com.
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.channel.ASCIIChannel;
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());
ASCIIChannel sc = new ASCIIChannel(new ISO87APackager());
sc.setHeader("56789".getBytes());
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) {
m.dump(System.out, ">>");
return true;
}
});
Thread t = new Thread(server);
t.start();
ASCIIChannel cs = new ASCIIChannel("127.0.0.1", 7776, new ISO87APackager());
cs.setLogger(l, "clientchannel");
ISOMsg m = new ISOMsg();
m.setMTI("0200");
m.set(2, "123456789");
m.setHeader("01234".getBytes());
cs.connect();
cs.send(m);
}
}
<log realm="server" at="Wed Dec 21 22:59:11 IST 2016.185" lifespan="45ms">
<iso-server>
listening on port 7776
</iso-server>
</log>
<log realm="clientchannel/127.0.0.1:7776" at="Wed Dec 21 22:59:11 IST 2016.198" lifespan="60ms">
<connect>
127.0.0.1:7776
</connect>
</log>
<log realm="clientchannel/127.0.0.1:7776" at="Wed Dec 21 22:59:11 IST 2016.209" lifespan="11ms">
<send>
<isomsg direction="outgoing">
<!-- org.jpos.iso.packager.ISO87APackager -->
<header>3031323334</header>
<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:39561" at="Wed Dec 21 22:59:11 IST 2016.210" lifespan="9ms">
<receive>
<isomsg direction="incoming">
<!-- org.jpos.iso.packager.ISO87APackager -->
<header>3031323334</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>3031323334</header>
>> <field id="0" value="0200"/>
>> <field id="bitmap" value="{2}" type="bitmap"/>
>> <field id="2" value="123456789"/>
>></isomsg>
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/397f5b4b-3092-40f1-8306-8cd34ef79a4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/93a3464a-baee-10bc-169f-e520d27423d8%40gmail.com.
Andres is absolutely right.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CAPazefBCjv%2BCpgd5KU%3DDoRrAhDWaDS1bZ%3DYG-CEJ3QGEqh6qGQ%40mail.gmail.com.
<receive>
, rest assured, jpos channel figured out the length and unpacked your message to display it correctly in the xml you see.0000 30 31 49 53 4F 31 30 32 30 30 32 30 30 30 30 30 01ISO10200200000
<header>303149534F31</header>
System.out.println(ISOUtil.hexdump(m.getHeader()));
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.ASCIIChannel;
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
{
int len = 31;
System.out.println(ISOUtil.zeropad(Integer.toString(len), 4));
System.out.println(ISOUtil.zeropad(String.valueOf(len), 4));
Logger l = new Logger();
l.addListener(new SimpleLogListener());
ASCIIChannel sc = new ASCIIChannel(new ISO87APackager());
sc.setHeader("56789".getBytes());
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()));
m.dump(System.out, ">>");
return true;
}
});
Thread t = new
Thread(server);
t.start();
AsciiChannelEx cs = new AsciiChannelEx("127.0.0.1", 7776, new ISO87APackager());
cs.setLogger(l, "clientchannel");
ISOMsg m = new ISOMsg();
m.setMTI("0200");
m.set(2, "123456789");
m.setHeader("01234".getBytes());
cs.connect();
cs.send(m);
}
}
AsciiChannelEx look like
import java.io.IOException;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOUtil;
import org.jpos.iso.channel.ASCIIChannel;
import org.jpos.iso.packager.ISO87APackager;
public class AsciiChannelEx extends ASCIIChannel {
public AsciiChannelEx(String string, int i, ISO87APackager iso87aPackager) {
super(string, i, iso87aPackager);
}
public AsciiChannelEx(ISO87APackager iso87aPackager) throws IOException {
super(iso87aPackager);
}
@Override
protected void sendMessageLength(int len) throws IOException {
try {
serverOut.write(ISOUtil.zeropad(String.valueOf(len), 4).getBytes());
}
catch (ISOException e) {
e.printStackTrace();
}
}
@Override
protected int getMessageLength() throws IOException, ISOException {
byte[] b = new byte[4];
serverIn.readFully(b, 0, 4);
int l = Integer.parseInt(new String(b));
return l;
}
}
Works on my machine :)
--
--
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/2f0d9cf8-cf13-4266-ad5e-00e8ba4c3020%40googlegroups.com.
--
--
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/29765221-732e-4626-9ec6-e161fd90417a%40googlegroups.com.
--
--
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/c4e51c27-4127-4e0f-9e56-780aa7e6d1be%40googlegroups.com.