connect to netcat server

36 views
Skip to first unread message

pks!!@

unread,
Dec 30, 2016, 7:30:15 AM12/30/16
to jPOS Users
Hi,

I am trying to send request to Netcat server (running on my local machine) using MUX but not getting success.

I am using as below code :

MUX modMux = QMUX.getMUX(this.cfg.get("target"));
ISOMsg resp = modMux.request(req, this.cfg.getLong("timeout"));



310_ubi_mux.xml file is as below

<?xml version="1.0" ?>
<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="ubi-mux">
 <in>receive</in>
 <out>send</out>
</mux>

311_ubi_channel.xml file is as below

<?xml version="1.0" ?>
<channel-adaptor name='adaptor' class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class="org.jpos.iso.channel.ASCIIChannel" logger="Q2" packager="org.jpos.iso.packager.ISO87APackagerBBitmap">
                <property name="host" value="localhost" />
<property name="port" value="3660" />
</channel>
<in>send</in> 
<out>receive</out> 
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>


chhil

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

​Go through your Q2 log. Spot exceptions if any.
Make sure ​
​your files show up as deployed and without errors.
​Look for entries which indicate that your client connected to the server.
Provide snippet of your ​
​class that contains request being made with the mux.​

-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/09dd7839-b0c3-4cc1-a302-b9bfee47985d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

pks!!@

unread,
Dec 30, 2016, 8:06:13 AM12/30/16
to jPOS Users
Hi,

I am gettins as below in log.
 
<log realm="org.jpos.q2.iso.ChannelAdaptor" at="Fri Dec 30 18:26:11 IST 2016.225">
  <warn>
    channel-receiver-ubi-host-receive
    <exception name="null">
    java.lang.NullPointerException
at org.jpos.iso.BaseChannel.createISOMsg(BaseChannel.java:609)
at org.jpos.iso.BaseChannel.createMsg(BaseChannel.java:606)
at org.jpos.iso.BaseChannel.receive(BaseChannel.java:634)
at org.jpos.q2.iso.ChannelAdaptor$Receiver.run(ChannelAdaptor.java:295)
at java.lang.Thread.run(Thread.java:745)
    </exception>
  </warn>
</log>

1st I started Netcat serevr & it runs very well.
But, I am not getting able to connect Netcat server through code. On first time startup my client code ( to send request ) Netcat server goes disconnect. 


Class Snippet from where i am trying to send request.

public class TestNetcat extends TxnSupport implements TransactionParticipant {

    @Override
    public void setConfiguration(Configuration cfg) throws ConfigurationException {
        this.cfg = cfg;
    }    
    
    @Override
    public void prepare(long l, Serializable context) {
        TxnContext ctx = (TxnContext) context;
        ctx.checkPoint("start" + new Date());
        try {            
            ISOMsg req = (ISOMsg) ctx.get("RMT");         
            MUX modMux = QMUX.getMUX(this.cfg.get("target"));
            ISOMsg resp = modMux.request(req, this.cfg.getLong("timeout"));
            if (resp != null) {
                  
            }else{
                System.out.println("Response NULL !!");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void commit(long l, Serializable srlzbl) {
        
    }

    @Override
    public void abort(long l, Serializable srlzbl) {
        
    }
    
}


Please guide me in right way.

Thanks & Regards
PKS

chhil

unread,
Dec 30, 2016, 8:43:08 AM12/30/16
to jpos-...@googlegroups.com

Do you see something like this in the log?

<log realm="channel/127.0.0.1:3660" at="Fri Dec 30 18:52:26 IST 2016.977" lifespan="1ms">
  <connect>
    localhost:3660
  </connect>
</log>

In your mux deploy add

<ready>adaptor.ready</ready> <!-- needs to be channel adaptor name + .ready-->

When you from the request from the participant, use the mux.isconnected() to check if its connected before sending the message.

-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.

chhil

unread,
Dec 30, 2016, 8:55:53 AM12/30/16
to jpos-...@googlegroups.com
One ore thing.... you should change your file numbering, have the channel deploy file prefixed number smaller than the mux deploy file prefixed number.
This way the channel initializes before the mux and does its connection. This way you wont run into a timing issue.

-chhil

pks!!@

unread,
Jan 2, 2017, 12:55:22 AM1/2/17
to jPOS Users
Hi Sir,
Sorry for delay.

Thanks for your guide. I did proper changes as per your instructions,
now my files are as below.

210_channel.xml

<?xml version="1.0" ?>
<channel-adaptor name='adaptor' class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class="org.jpos.iso.channel.ASCIIChannel" logger="Q2">
        <property name="host" value="localhost" />
<property name="port" value="36605" />
</channel>
<in>xx-host-send</in>
<out>xx-host-receive</out> 
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>



211_mux.xml

<?xml version="1.0" ?>
<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="mux">
 <in>xx-host-receive</in>
 <out>xx-host-send</out>
 <ready>adaptor.ready</ready>
</mux>

But, I am getting same error.When i start my application & at the time of deploy 
my application shows as below error & net-cat server get disconnected without show any error on console.


<log realm="com.tm.TransactionManager" at="Mon Jan 02 11:11:15 IST 2017.953">
  <info>
    au-34 start
  </info>
</log>
<log realm="com.tm.TransactionManager" at="Mon Jan 02 11:11:15 IST 2017.953">
  <info>
    au-19 start
  </info>
</log>
<log realm="com.tm.TransactionManager" at="Mon Jan 02 11:11:15 IST 2017.953">
  <info>
    au-27 start
  </info>
</log>
<log realm="org.jpos.q2.iso.ChannelAdaptor" at="Mon Jan 02 11:11:15 IST 2017.953">
  <warn>
    channel-receiver-host-receive
    <exception name="null">
    java.lang.NullPointerException
at org.jpos.iso.BaseChannel.createISOMsg(BaseChannel.java:609)
at org.jpos.iso.BaseChannel.createMsg(BaseChannel.java:606)
at org.jpos.iso.BaseChannel.receive(BaseChannel.java:634)
at org.jpos.q2.iso.ChannelAdaptor$Receiver.run(ChannelAdaptor.java:295)
at java.lang.Thread.run(Thread.java:745)
    </exception>
  </warn>
</log>
<log realm="com.tm.TransactionManager" at="Mon Jan 02 11:11:15 IST 2017.953">
  <info>
    au-17 start
  </info>
</log>


Here my point is that, as per my knowledge netcat server runs & accept on TCP than,
is above xml configuration file (210_channel.xml) correct way to connect this server.

Please point me, where am i missing?

Thanks & regards
pks


Victor Salaman

unread,
Jan 2, 2017, 1:08:01 AM1/2/17
to jpos-...@googlegroups.com
Your channel does not contain a packager... Please fix

<?xml version="1.0" ?>
<channel-adaptor name='adaptor' class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel name="xx-channel" class="org.jpos.iso.channel.ASCIIChannel" logger="Q2" realm="xx-channel" 
                        packager="org.jpos.iso.packager.GenericPackager"
        <property name="host" value="localhost" />
<property name="port" value="36605" />
                <property name="packager-config" value="cfg/packager/xx.xml" />
</channel>
<in>xx-host-send</in>
<out>xx-host-receive</out> 
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>

--
--
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.

pks!!@

unread,
Jan 2, 2017, 1:44:38 AM1/2/17
to jPOS Users
Hi,

Thanks for your right guidance.Now, it works.
But, here i have another requirement. I have to sent request ( hexdump of isomessage as string ) to a server, listening on TCP using MUX & above defined configuration file.
Please guide me the right process.

Thanks & Regards
pks

Victor Salaman

unread,
Jan 2, 2017, 1:53:26 AM1/2/17
to jpos-...@googlegroups.com
You would need a packager to match what your endpoint is expecting (hexdump of isomessage as string). If you need additional guidance, may I suggest the jPOS programmer's guide, or you invest in consulting through sa...@jpos.org ?

/V 

--
--
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.

Mark Salter

unread,
Jan 2, 2017, 11:46:58 AM1/2/17
to jpos-...@googlegroups.com
On 02/01/17 06:44, pks!!@ wrote:
> But, here i have another requirement.
Then you really need a new thread/post?

--
Mark
Reply all
Reply to author
Forward
0 new messages