TCP connection error when connecting to client

225 views
Skip to first unread message

taha yassine benbrahim

unread,
Mar 27, 2017, 6:19:43 AM3/27/17
to jPOS Users
Hi I am new in jpos, I have developed a ServerForward server: but I can't connect to the client, this is the implementation :

package client;

import java.io.IOException;

import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISORequestListener;
import org.jpos.iso.ISOSource;
import org.jpos.iso.MUX;
import org.jpos.q2.Q2;
import org.jpos.util.NameRegistrar;

public class ServerListener implements ISORequestListener {

public static void main(String[] args) {
Q2 q2 = new Q2();
q2.start();
}

@Override
public boolean process(ISOSource isoSrc, ISOMsg isoMsg) {

try {
if (isoMsg.getMTI().equals("0800")) {
ISOMsg reply = (ISOMsg) isoMsg.clone();
reply.setResponseMTI();
reply.set(39, "00");
isoSrc.send(reply);
return true;
}
// send request to server B
MUX mux = (MUX) NameRegistrar.getIfExists("mux.jpos-client-mux");
ISOMsg reply = mux.request(isoMsg, 10 * 1000);
if (reply != null) {
System.out.println(new String(reply.pack()));
reply.set(125, "RESPONSE FROM SERVER A");
isoSrc.send(reply);
}
} catch (ISOException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}

}
------------------------------------10_server.xml--------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<server class="org.jpos.q2.iso.QServer" logger="Q2" name="MyISOServer">
    <attr name="port" type="java.lang.Integer">8001</attr>
    <attr name="maxSessions" type="java.lang.Integer">20</attr>
    <attr name="minSessions" type="java.lang.Integer">10</attr>

    <channel name="ClientChannel" class="org.jpos.iso.channel.HEXChannel" logger="Q2"
              packager="org.jpos.iso.packager.GenericPackager">
<property name="packager-config" value="basic.xml" /> 
    </channel>

    <request-listener class="client.ServerListener" logger="Q2">
        <property name="space" value="transient:default" />
        <property name="queue" value="TransactionQueue" />
        <property name="timeout" value="10000" />
    </request-listener>
</server>
--------------------------------my packager -------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE isopackager SYSTEM "genericpackager.dtd">
<isopackager>
  <isofield
      id="0"
      length="4"
      name="MESSAGE TYPE INDICATOR"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="1"
      length="64"
      name="BIT MAP"
      class="org.jpos.iso.IFA_BITMAP"/>
  <isofield
      id="3"
      length="6"
      name="PROCESSING CODE"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="4"
      length="12"
      name="AMOUNT, TRANSACTION"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="7"
      length="10"
      name="TRANSMISSION DATE AND TIME"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="11"
      length="6"
      name="SYSTEM TRACE AUDIT NUMBER"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="44"
      length="25"
      name="ADITIONAL RESPONSE DATA"
      class="org.jpos.iso.IFA_LLCHAR"/>
  <isofield
      id="105"
      length="999"
      name="RESERVED ISO USE"
      class="org.jpos.iso.IFA_LLLCHAR"/>
</isopackager>
-------------------------15_channel.xml-------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<channel-adaptor name='jpos-client-adaptor' class="org.jpos.q2.iso.ChannelAdaptor"
logger="Q2">
<channel class="org.jpos.iso.channel.HEXChannel" logger="Q2"
packager="org.jpos.iso.packager.GenericPackager">
<property name="packager-config" value="basic.xml" /> 
<property name="host" value="127.0.0.1"/>
<property name="port" value="8000" />
</channel>
<in>jpos-client-send</in>
<out>jpos-client-receive</out>
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>
-----------------------------------20_mux.xml----------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="jpos-client-mux">
<in>jpos-client-receive</in>
<out>jpos-client-send</out>
</mux>
---------------------------------------------------------------------------------------------------

I just want to receive messages from client and forward it to server, and the same think from server to client 

Thanks 

Andrés Alcarraz

unread,
Mar 27, 2017, 8:00:43 AM3/27/17
to jpos-...@googlegroups.com

Hi, I'm afraid you didn't provide all the information we might need to hepl you.

Fisto of all, we have no idea to who you are trying to connect, in the sense that we don't know if the channel/packager matches their scpecs, you need to provide access to the output of your implementation, maskarading every sensible information.

Are you sure the messages are arriving to your server?

How do you know they aren't getting to the server you are connecting to?

Are you absolutely sure your channel/packager configuration matches the other server specs? If so what did the other end told you so that you think the message does not arrives?

What do you mean you can't connect, are you sure the other end is up in you machine and listening on port 8000? Did you run netstat to verify that?


Please provide all the answers to the question asked if you want us to be able to help you without some superpower someone in the list could have to divine what could be going on.

Best regards and please don't forget to answer every question so we can have the needed information to help you.

Andrés Alcaraz

El 27/03/17 a las 07:19, taha yassine benbrahim 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/83396c29-db3c-4a74-be25-cf6ed6a8c326%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

chhil

unread,
Mar 27, 2017, 8:17:26 AM3/27/17
to jpos-...@googlegroups.com

Server is listening on 8001 and client is connecting on 8000 may be your problem.

-chhil


taha yassine benbrahim

unread,
Mar 27, 2017, 8:43:01 AM3/27/17
to jPOS Users
I am just testing my application, on my own computer, and I want to connect to the client via 127.0.0.1 and port 8000 and sending a message from a TCP client and received from my application then forward it to a TCP server, I am using Hercules for CLIENT TCP and SERVER TCP listening on port 8001, and for doing that I have done this solution  

Andrés Alcarraz

unread,
Mar 27, 2017, 8:47:16 AM3/27/17
to jpos-...@googlegroups.com

Hi, you still didn't provide any of the information requested, this information is simply not enaugh for us to help you.

Please responde to my questions in my other response, we have no idea what is going on on your machine, and I'm afraid your explanation is not complete enough.

You NEED to response those questions precisely if you want help from us, since otherwise we have not enagh to help you, please help us help you and ask a smart question

Regards
El 27/03/17 a las 09:43, taha yassine benbrahim 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.

taha yassine benbrahim

unread,
Mar 27, 2017, 8:56:37 AM3/27/17
to jPOS Users
Are you sure the messages are arriving to your server? 
No, because I can't send a message from the client because I have this error. and I can't connect to the client 
And the server is listening in the 8001 port when, netstat show that is listening 
but I can't test if its working until I coonect to the client and send a message 

Le lundi 27 mars 2017 11:19:43 UTC+1, taha yassine benbrahim a écrit :

Andrés Alcarraz

unread,
Mar 27, 2017, 9:56:25 AM3/27/17
to jpos-...@googlegroups.com



El 27/03/17 a las 09:56, taha yassine benbrahim escribió:
Are you sure the messages are arriving to your server? 
No, because I can't send a message from the client because I have this error. and I can't connect to the client 
And the server is listening in the 8001 port when, netstat show that is listening
So if your server is listening and your client, which I understand is not jPOS, is not being able to connect, it's not a jpos issue but a issue of your client software. Again the problem is that it's not able to connecto? or that it sends messages that are not being received by the server once the connection has been established?

Your responses are so vague that it's difficult to me to understang what is going on. Please be more specific.


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

taha yassine benbrahim

unread,
Mar 27, 2017, 10:54:59 AM3/27/17
to jPOS Users
My problem is that I am new in jpos, and I want to test my application, my application consist of having a Server A that Link between Server B and Client (requester) So I have to implement a client to send a message to server A, then forwarding the message to server B, then waiting to response from Server B and forward it to Client, the server A is listening On 8001 and forward the messages from client via port 8000 and host address 127.0.0.1 to server B, this is my final implementation:

My Generic Packager (basic.xml):

------------------------------------------------------------------------------------
00_logger.xml :

--------------------------------------------------------------------------------------

<logger name="Q2" class="org.jpos.q2.qbean.LoggerAdaptor">
  <log-listener class="org.jpos.util.SimpleLogListener" />
  <log-listener class="org.jpos.util.BufferedLogListener">
    <property name="max-size" value="100" />
    <property name="name" value="logger.Q2.buffered" />
  </log-listener>

  <log-listener class="org.jpos.util.DailyLogListener">
    <property name="window" value="86400" /> <!-- optional, default one day -->
    <!--needed-->
    <property name="prefix" value="log/q2" />
    <property name="suffix" value=".log"/> <!-- optional -->
    <!--optional the default is "-yyyy-MM-dd" -->
    <property name="date-format" value="-yyyy-MM-dd-HH"/>
    <!--optional the default is gzip-->
    <property name="compression-format" value="gzip"/> 
  </log-listener>
</logger>

10_server_A.xml :
---------------------------------------------------------------------------------------------

<server class="org.jpos.q2.iso.QServer" logger="Q2" name="Server-A">
    <attr name="port" type="java.lang.Integer">8001</attr>
    <attr name="maxSessions" type="java.lang.Integer">20</attr>
    <attr name="minSessions" type="java.lang.Integer">10</attr>

    <channel name="Server-A-Channel" class="org.jpos.iso.channel.HEXChannel" logger="Q2"
              packager="org.jpos.iso.packager.GenericPackager">
<property name="packager-config" value="basic.xml" /> 
    </channel>

    <request-listener class="serverFront.ServerListener" logger="Q2">
        <property name="space" value="transient:default" />
        <property name="queue" value="TransactionQueue" />
        <property name="timeout" value="10000" />
    </request-listener>
</server>

11_server_B.xml :

---------------------------------------------------------------------------------------------------------
<server class="org.jpos.q2.iso.QServer" logger="Q2" name="Server-B">
    <attr name="port" type="java.lang.Integer">8000</attr>
    <attr name="maxSessions" type="java.lang.Integer">100</attr>
    <attr name="minSessions" type="java.lang.Integer">10</attr>

    <channel name="Server-B-Channel" class="org.jpos.iso.channel.HEXChannel" logger="Q2"
              packager="org.jpos.iso.packager.GenericPackager">
<property name="packager-config" value="basic.xml" />
    </channel>

    <request-listener class="serverB.ServerBListener" logger="Q2">
        <property name="space" value="transient:default" />
        <property name="queue" value="TransactionQueue" />
        <property name="timeout" value="10000" />
    </request-listener>
</server>

30_client_channel.xml:
-----------------------------------------------------------------------------------------------

<channel-adaptor name='client-adaptor' class="org.jpos.q2.iso.ChannelAdaptor"
logger="Q2">

<channel class="org.jpos.iso.channel.HEXChannel" packager="org.jpos.iso.packager.GenericPackager"
logger="Q2">
<property name="packager-config" value="basic.xml" />
<!-- Server A Address -->
<property name="host" value="127.0.0.1" />
<property name="port" value="8001" />
</channel>

<in>client-send</in>
<out>client-receive</out>
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>

32_server_A_forward_channel.xml :
-------------------------------------------------------------------------------------------------

<channel-adaptor name='server-A-adaptor' class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class="org.jpos.iso.channel.HEXChannel" 
packager="org.jpos.iso.packager.GenericPackager" logger="Q2">
<property name="packager-config" value="basic.xml" />
<property name="host" value="127.0.0.1" />
<property name="port" value="8000" />
</channel>
<in>serverA-forward-send</in>
<out>serverA-forward-receive</out>
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>

40_client_mux.xml :
--------------------------------------------------------------------------------------------------


<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="client-mux">
<in>client-receive</in>
<out>client-send</out>
</mux>

41_server_A_forward_mux.xml:
---------------------------------------------------------------------------------------------------

<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="serverA-forwarder-mux">
<in>serverA-forward-receive</in>
<out>serverA-forward-send</out>
</mux>

99_sysmon.xml:
-------------------------------------------------------------------------------------------------

<sysmon logger="Q2">

<attr name="sleepTime" type="java.lang.Long">3600000</attr>

<attr name="detailRequired" type="java.lang.Boolean">true</attr>

</sysmon>


The client for sending the message :
package requester;

import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOUtil;
import org.jpos.iso.MUX;
import org.jpos.q2.Q2;
import org.jpos.q2.iso.QMUX;
import org.jpos.util.NameRegistrar;

public class Client {
public static void startQ2() {
Q2 q2 = new Q2();
q2.start();
System.out.println("Starting Deployment");
}

public static void main(String[] args) {
startQ2();
// give some delay before sent req, cz q2 deployment is async
ISOUtil.sleep(5000);

// Process send and receive data
try {
MUX mux = (MUX) NameRegistrar.getIfExists("mux.client-mux");
ISOMsg msg=createReqMsg();
ISOMsg reply = mux.request(msg, 10 * 1000);
System.out.println(new String(reply.pack()));

} catch (ISOException e) {
e.printStackTrace();
}
}

public static ISOMsg createReqMsg() {
ISOMsg reqMsg = new ISOMsg();
reqMsg.setHeader("0066".getBytes());
try {
reqMsg.set(3, "201234");
reqMsg.set(4, "10000");
reqMsg.set(7, "110722180");
reqMsg.set(11, "123456");
reqMsg.set(44, "A5DFGR");
reqMsg.set(105, "ABCDEFGHIJ 1234567890");
} catch (ISOException e) {
e.printStackTrace();
}
return reqMsg;
}
}


server B :

package serverB;

import java.io.IOException;

import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISORequestListener;
import org.jpos.iso.ISOSource;

public class ServerBListener implements ISORequestListener {

@Override
public boolean process(ISOSource requester, ISOMsg reqMsg) {
try {
ISOMsg respMsg = (ISOMsg) reqMsg.clone();
respMsg.set(124, "HI CLIENT, THIS IS DATA FROM ME! B");
respMsg.set(39, "00");
respMsg.setResponseMTI();
requester.send(respMsg);
} catch (ISOException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}

}


And Server A for forwarding:

package serverFront;

import java.io.IOException;

import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISORequestListener;
import org.jpos.iso.ISOSource;
import org.jpos.iso.MUX;
import org.jpos.q2.Q2;
import org.jpos.util.NameRegistrar;

public class ServerAListener implements ISORequestListener {

public static void main(String[] args) {
Q2 q2 = new Q2();
q2.start();
}

@Override
public boolean process(ISOSource isoSrc, ISOMsg isoMsg) {

try {
if (isoMsg.getMTI().equals("0800")) {
ISOMsg reply = (ISOMsg) isoMsg.clone();
reply.setResponseMTI();
reply.set(39, "00");
isoSrc.send(reply);
return true;
}
// send request to server B
MUX mux = (MUX) NameRegistrar.getIfExists("mux.serverA-forwarder-mux");
ISOMsg reply = mux.request(isoMsg, 10 * 1000);
if (reply != null) {
System.out.println(new String(reply.pack()));
reply.set(125, "RESPONSE FROM SERVER A");
isoSrc.send(reply);
}
} catch (ISOException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}

}


notice that there is no specification, is just a message that i want to send from the client, and forward it via server A to B, then waiting a response from B then send it to the client, thats all,

taha yassine benbrahim

unread,
Mar 27, 2017, 11:06:08 AM3/27/17
to jPOS Users
And when I run the client, it always show me java.lang.NullPointerException for " ISOMsg reply = mux.request(msg, 10 * 1000);"


Le lundi 27 mars 2017 11:19:43 UTC+1, taha yassine benbrahim a écrit :

Andrés Alcarraz

unread,
Mar 27, 2017, 12:58:28 PM3/27/17
to jpos-...@googlegroups.com



El 27/03/17 a las 12:06, taha yassine benbrahim escribió:
And when I run the client, it always show me java.lang.NullPointerException for " ISOMsg reply = mux.request(msg, 10 * 1000);"
That's because your mux is null. If that is the code in your request listener, then the server is already receiving messages. Or that's code in another client program?
If that's the case, then the problem is that your mux is null, and you sshould show us the client program so we can assist you.

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

taha yassine benbrahim

unread,
Mar 28, 2017, 7:20:58 AM3/28/17
to jPOS Users
Hi, where I have to place my generic packager, because I have placed in deploy directory, and mention this uri :<property name="packager-config" value="/deploy/basic.xml" /> but I got this message  Nested:java.io.FileNotFoundException: C:\WorkspaceMars\Pcard\JposProject\deploy\basic.xml


Le lundi 27 mars 2017 11:19:43 UTC+1, taha yassine benbrahim a écrit :

Andrés Alcarraz

unread,
Mar 28, 2017, 2:20:39 PM3/28/17
to jPOS Users
the url is relative to the directory from where you execute the program, don't know exactly your setup or how you are launching the program so cannot help you more

Andrés Alcarraz

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