Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

strange problem with opening tcp socket

by gdanenb (Acolyte)
on Dec 24, 2011 at 16:47 UTC ( #945031=perlquestion: print w/replies, xml ) Need Help??
gdanenb has asked for the wisdom of the Perl Monks concerning the following question:

I have very strange problem...
I've written a script that uses REST::Client module to run tests over HTTP.
Its working fine besides against one particular java application with embedded tomcat(on Linux)
When REST Client opens tcp socket, the server immediately aborts it (SYN->SYN,ACK->ACK and then FYN,ACK from server),
As a result of closing connection by server, LWP module prints "500 Server closed connection without sending any data back".
The java application is a production one and dont make any problem when accessed from another applications or web ui.

I found some old script on the system that opens socket successfully, the script implements socket directly:

$AF_INET = 2; $SOCK_STREAM = 1; $sockaddr = 'S n a4 x8'; $this = pack($sockaddr, $AF_INET, 0, $thisaddr); $that = pack($sockaddr, $AF_INET, $port, $thataddr); ($name,$aliases,$proto) = getprotobyname('tcp'); socket(S, $AF_INET, $SOCK_STREAM, $proto) || die "socket: $!"; bind(S, $this) || die "bind: $!"; if (connect(S, $that)) { print connetced } select(S); $| = 1; select(STDOUT); print S "$USER_VALUE CHECK $host\n";

I debugged REST and underlying modules and saw that parameter passed to socket are similar (besides $sockaddr = 'S n a4 x8' which I didnt understand..)
What is the problem here ?

Replies are listed 'Best First'.
Re: strange problem with opening tcp socket
by Anonymous Monk on Dec 24, 2011 at 17:32 UTC

    What is the problem here ?

    Not enough of the right kind of information , like LWP::Debug output from successful and failing request, or WireShark output of same, or actual REST::Client code that demonstrates the problem (I this might not be possible)

    The $sockaddr is just a pack template, a DIY way to prepare an adress for socket, use IO::Socket instead

      Please ignore this post, the problem was in tomcat implementation of java program.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://945031]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2018-02-23 04:47 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (300 votes). Check out past polls.