HELP! Channel.receive hangs but Wireshark Shows Reply

202 views
Skip to first unread message

Yeya

unread,
May 20, 2013, 12:26:23 PM5/20/13
to jpos-...@googlegroups.com
Hi All

I am sending 0800 to a server and sometimes I get the reply sometimes I do not (times out on read at channel.receive). When I do a TCP sniff I see the server responded but client sends RST, ACK

Please see below stacktrace and wireshark trace

       at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:150)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at java.io.DataInputStream.readFully(DataInputStream.java:195)
at org.jpos.iso.channel.ASCIIChannel.getMessageLength(ASCIIChannel.java:96)
at org.jpos.iso.BaseChannel.receive(BaseChannel.java:664)

This is my code

BaseChannel channelx = new ASCIIChannel (
"172.20.28.78", 18584, new ISO87APackager());
                                ((LogSource)channelx).setLogger (logger, "zap-channelx");
                                channelx.setTimeout(10000);
                               
channelx.connect();
channelx.send (msg);
resp = channelx.receive();
channelx.disconnect ();

chhil

unread,
May 20, 2013, 12:42:42 PM5/20/13
to jpos-...@googlegroups.com
What was the actual exception that was thrown?
It seems like the server stops listening causing the RST,ACK.

-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 "jPOS Users" group.
Please see http://jpos.org/wiki/JPOS_Mailing_List_Readme_first
To post to this group, send email to jpos-...@googlegroups.com
To unsubscribe, send email to jpos-users+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jpos-users
 
---
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ngetha Mwangi

unread,
May 20, 2013, 12:52:04 PM5/20/13
to jpos-...@googlegroups.com
IOException in transport block
java.net.SocketTimeoutException: Read timed out


You received this message because you are subscribed to a topic in the Google Groups "jPOS Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jpos-users/G8o7NneUzHs/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to jpos-users+...@googlegroups.com.

Mark Salter

unread,
May 20, 2013, 6:01:27 PM5/20/13
to jpos-...@googlegroups.com
On 20/05/2013 17:26, Yeya wrote:
> I am sending 0800 to a server and sometimes I get the reply sometimes I
> do not (times out on read at channel.receive). When I do a TCP sniff I
> see the server responded but client sends RST, ACK
Sounds like a server, network or mismatch on structure problem...
>
> Please see below stacktrace and wireshark trace
>
>
> This is my code
>
> BaseChannel channelx = new ASCIIChannel (
> "172.20.28.78", 18584, new ISO87APackager());
> ((LogSource)channelx).setLogger (logger,
> "zap-channelx");
Please share all the details logged from the Channel, I am particularly
interested in the message length, which I suspect is mismatched or badly
formed (or another format) causing your receive to wait for a large
number of bytes that will never arrive.

If you can provide a hex dump from wireshark of the response, then that
will also help.


> channelx.setTimeout(10000);
Is the server guaranteed to respond inside the 10 seconds given?
Perhaps this needs to be larger - ask the owner of the server?

>
> channelx.connect();
> channelx.send (msg);
> resp = channelx.receive();
> channelx.disconnect ();

This is test code and not really worth 'fixing', you should seek to use
a MUX and other jPOS components, that will make things easier for you
and us.


--
Mark

Yeya

unread,
May 21, 2013, 4:48:38 AM5/21/13
to jpos-...@googlegroups.com
Hi Mark

Thank you for the prompt response, please find my wireshark hex dump and also the answers to the other questions below. Kindly assist.

Hex Dump
ISO Client Request (.91) to ISO Server (.78)
3010 110.732450000 172.20.8.91 172.20.28.78 TCP 123 58365 > 18584 [PSH, ACK] Seq=1 Ack=1 Win=65536 Len=69
0000   00 00 0c 07 ac 14 84 4b f5 a2 54 dd 08 00 45 00  .......K..T...E.
0010   00 6d 47 75 40 00 80 06 36 44 ac 14 08 5b ac 14  .mGu@...6D...[..
0020   1c 4e e3 fd 48 98 7a ae 6d 9c dd ef f3 22 50 18  .N..H.z.m...."P.
0030   01 00 86 10 00 00 30 30 36 35 30 38 30 30 38 32  ......0065080082
0040   33 38 30 30 30 30 30 30 30 30 30 30 30 30 30 34  3800000000000004
0050   30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 35  0000000000000005
0060   32 31 31 30 33 39 32 37 31 32 36 34 37 38 30 30  2110392712647800
0070   30 35 32 31 30 35 32 31 33 30 31                 05210521301

00000c07ac14844bf5a254dd08004500006d4775400080063644ac14085bac141c4ee3fd48987aae6d9cddeff3225018010086100000303036353038303038323338303030303030303030303030303430303030303030303030303030303035323131303339323731323634373830303035323130353231333031

ISO Server Response
3027 110.918981000 172.20.28.78 172.20.8.91 TCP 125 18584 > 58348 [PSH, ACK] Seq=1 Ack=71 Win=65466 Len=71
0000   84 4b f5 a2 54 dd 70 81 05 e8 76 7f 08 00 45 00  .K..T.p...v...E.
0010   00 6f 07 86 40 00 7f 06 77 31 ac 14 1c 4e ac 14  .o..@...w1...N..
0020   08 5b 48 98 e3 ec cb 4a 90 0a 61 3b b4 4e 50 18  .[H....J..a;.NP.
0030   ff ba 9a bc 00 00 30 30 36 37 30 38 31 30 38 32  ......0067081082
0040   33 38 30 30 30 30 30 32 30 30 30 30 30 30 30 34  3800000200000004
0050   30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 35  0000000000000005
0060   32 31 31 30 32 32 33 32 31 32 36 34 37 38 31 30  2110223212647810
0070   32 32 33 32 30 35 32 31 30 30 33 30 31           2232052100301

844bf5a254dd708105e8767f08004500006f078640007f067731ac141c4eac14085b4898e3eccb4a900a613bb44e5018ffba9abc00003030363730383130383233383030303030323030303030303034303030303030303030303030303030353231313032323332313236343738313032323332303532313030333031

ISO Client
3028 110.919103000 172.20.8.91 172.20.28.78 TCP 54 58348 > 18584 [RST, ACK] Seq=71 Ack=72 Win=0 Len=0
0000   00 00 0c 07 ac 14 84 4b f5 a2 54 dd 08 00 45 00  .......K..T...E.
0010   00 28 47 76 40 00 80 06 36 88 ac 14 08 5b ac 14  .(Gv@...6....[..
0020   1c 4e e3 ec 48 98 61 3b b4 4e cb 4a 90 51 50 14  .N..H.a;.N.J.QP.
0030   00 00 95 53 00 00                                ...S..

Is the server guaranteed to respond inside the 10 seconds given? 
Perhaps this needs to be larger - ask the owner of the server? 

- If I do not set the timeout, it blocks forever. When I receive successful responses, they are received in milliseconds.

This is test code and not really worth 'fixing', you should seek to use 
a MUX and other jPOS components, that will make things easier for you 
and us.
 
- The examples from the jPOS developer guide on MUX/QMUX are confusing, I cant see the place where the QMUX is instantiated, only references to get / register the QMUX in the NameRegistrar.

Hex Dump
This is test code and not really worth 'fixing', you should seek to use 
a MUX and other jPOS components, that will make things easier for you 
and us. 

chhil

unread,
May 21, 2013, 6:01:32 AM5/21/13
to jpos-...@googlegroups.com

From the wireshark dump:

    public static void main(String[] args) throws IOException, ISOException {

        Logger logger = new Logger();
        logger.addListener(new SimpleLogListener(System.out));
        ISO87APackager p = new ISO87APackager();
        p.setLogger(logger, "");
// Hex obtained from the wireshark dump
        String hexReq = "3038303038323338303030303030303030303030303430303030303030303030303030303035323131303339323731323634373830303035323130353231333031";
        String hexRsp = "30383130383233383030303030323030303030303034303030303030303030303030303030353231313032323332313236343738313032323332303532313030333031";
        ISOMsg m = new ISOMsg();
        m.setPackager(p);
        try {
//         m.unpack(ISOUtil.hex2byte(hexRsp));
           m.unpack(ISOUtil.hex2byte(hexReq));
           m.dump(System.out, "");
        }
        catch (ISOException e) {
            e.printStackTrace();
            m.dump(System.out, "");
        }

        BaseChannel channelx = new ASCIIChannel("127.0.0.1", 44444, p);

        ((LogSource) channelx).setLogger(logger, "zap-channelx");
        channelx.setTimeout(10000);

        channelx.connect();
        channelx.send(m);
        ISOMsg resp = channelx.receive();
        channelx.disconnect();

    }
The request you send
<isomsg>
  <!-- org.jpos.iso.packager.ISO87APackager -->
  <field id="0" value="0800"/>
  <field id="7" value="0521103927"/>
  <field id="11" value="126478"/>
  <field id="12" value="000521"/>
  <field id="13" value="0521"/>
  <field id="70" value="301"/>
</isomsg>
Length prepended 0065.

The response you received from the server
<isomsg>
  <!-- org.jpos.iso.packager.ISO87APackager -->
  <field id="0" value="0810"/>
  <field id="7" value="0521102232"/>
  <field id="11" value="126478"/>
  <field id="12" value="102232"/>
  <field id="13" value="0521"/>
  <field id="39" value="00"/>
  <field id="70" value="301"/>
</isomsg>
Server has prepended a length of 0067. If I send the response back through netcat
00670810823800000200000004000000000000000521102232126478102232052100301 , its correctly handled by the channel and packager.

Your channel is correct, and the packager is aligned correctly for your 0800/0810 messages.

The exception you get is when the server does not respond and the 10 second timeout you have set(  channelx.setTimeout(10000); ) kicks in and the exception gets logged.

Easily simulated if you have a netcat server listening and not responding back with a response. You should follow up with the server side.


Most of the work that you do for setting packagers , channels , loggers is achieved by configuring qmux, server , channel deploy files. The framework pick these up and connects to remote. All you have to do is get the qmux object from the nameregistrar instance and do a request(...).


-chhil

--

Mark Salter

unread,
May 21, 2013, 7:23:13 AM5/21/13
to jpos-...@googlegroups.com


On Tuesday, May 21, 2013 9:48:38 AM UTC+1, Yeya wrote:

Thank you for the prompt response, please find my wireshark hex dump and also the answers to the other questions below. Kindly assist.

I really wanted the Channel Logger output as well or instead of the wireshark hex dump...

... but given Chhil's substantive response , I will stop replying and admire his work, perhaps you could do the same and then ask the Server admins what they might be doing to cause 'your' problem (like not responding or responding to the wrong connection perhaps?)


- The examples from the jPOS developer guide on MUX/QMUX are confusing, I cant see the place where the QMUX is instantiated, only references to get / register the QMUX in the NameRegistrar.

You should persevere as it really is very easy once you get your QBeans defined and deployed.

Perhaps the subject of a new dedicated thread after checking the previous posts and guidance on this.

--
Mark

Yeya

unread,
May 21, 2013, 10:09:10 AM5/21/13
to jpos-...@googlegroups.com
All, Thank you for your comments on this.

I am following up with the Server Admin, just sent him a copy of my small app to run on that host and share the details.
Reply all
Reply to author
Forward
0 new messages