Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

SSL Soap Server daemon stopping

by perlchild (Acolyte)
on Aug 19, 2008 at 23:26 UTC ( [id://705367]=perlquestion: print w/replies, xml ) Need Help??

perlchild has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl soap server daemon that runs continuously but since I added SSL functionality the server will run for a while and then shuts down on its own. I have tried starting the server with the stdout and stderr redirected to a file but I get no output or errors.

The following is the code for the server:
#!/usr/bin/perl -w use HTTP::Daemon::SSL; use HTTP::Status; use SOAP::Lite; use SOAP::Transport::HTTP; use XML::Simple; use TTPSubmit; # Make sure you have a certs/ directory with "server-cert.pem" # and "server-key.pem" in it before running this! my $daemon = new HTTP::Daemon::SSL SSL_key_file => '(takenout)server-key.pem', SSL_cert_file => '(takenout)server-cert.pem', LocalPort => 8080; my $soap = SOAP::Transport::HTTP::Server -> new ( ) -> dispatch_to('TTPSubmit'); print "Please contact me at: <URL:", $daemon->url, ">\n"; while (my $conn = $daemon->accept()) { while (my $request = $conn->get_request()) { $soap->request($request); $soap->handle(); my $response = $soap->response(); $conn->send_response($response); } $conn->close; undef($conn); }

Any help with this is greatly appreciated.

Replies are listed 'Best First'.
Re: SSL Soap Server daemon stopping
by Anonymous Monk on Aug 20, 2008 at 04:46 UTC
    Add error checking (...->new or die) and turn on debugging ($HTTP::Daemon::DEBUG=1; use IO::Socket::SSL qw(debug3);).

      Here is the output from my debug session using the debug statements you suggested.

      DEBUG: .../IO/Socket/SSL.pm:202: CA file certs/my-ca.pem not found, us +ing CA path instead. DEBUG: .../IO/Socket/SSL.pm:1382: new ctx 153784112 DEBUG: .../IO/Socket/SSL.pm:421: no socket yet DEBUG: .../IO/Socket/SSL.pm:423: accept created normal socket HTTP::Da +emon::ClientConn::SSL=GLOB(0x9ddf480) DEBUG: .../IO/Socket/SSL.pm:439: starting sslifying DEBUG: .../IO/Socket/SSL.pm:479: Net::SSLeay::accept -> -1 DEBUG: .../IO/Socket/SSL.pm:1131: SSL accept attempt failed with unkno +wn errorerror:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http reque +st DEBUG: .../IO/Socket/SSL.pm:1417: free ctx 153784112 open=153784112 DEBUG: .../IO/Socket/SSL.pm:1420: OK free ctx 153784112

      I will need help interpreting this output but it looks like something or someone tried to submit to the soap server and it failed. Is that what I'm seeing here? If so, how can I make it not stop the process when this happens?

      I think I may have figured out what the problem was. Since it looked like something was trying to access the soap server process in the above debug output, I thought maybe a web bot crawler is doing that. So I put a robots.txt file in my root web directory disallowing all agents from accessing the soap server directory. It has been running now for over 24 hours without stopping. It was stopping every evening around 7pm but now it seems okay. Hope this helps someone else that may be having a similar problem.

      Unfortunately, the preceeding paragraph about the robots.txt file, did not fix the problem. The server is still stopping intermittedly!!

        error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request
        means it tried to speak HTTP to a HTTPS port

        If so, how can I make it not stop the process when this happens?
        I don't see how that would stop the server, but you can just restart the daemon (put it in a loop)

Re: SSL Soap Server daemon stopping
by Eyck (Priest) on Aug 20, 2008 at 16:45 UTC
    Does the server actualy shut itself down, or does it just stop working ( hang )?

    Running out of enthropy has this annoying property of SSL code waiting for more enthropy to become available, thus behaving similarly to what you describe.

      Yes Eyck, the soap server process completely stops. Its no longer a running process and not listed in the ps output.

        If it's easy to reproduce, I would suggest trying to run your daemon under 'strace -f'

        If it takes more time to reproduce, I guess I would still try running it with strace via

        strace -o daemon.log -f -p $pid
        because it might be something inside your ssl library and segfault there won't be easy to catch just with logging from inside.

        Here's a fix :) If something dies, add some eval {};warn $@ if $@;
        #!/usr/bin/perl -w use HTTP::Daemon::SSL; use HTTP::Status; use SOAP::Lite; use SOAP::Transport::HTTP; use XML::Simple; use TTPSubmit; while(1){ # infinite loop, if Daemon stop for some reason # Make sure you have a certs/ directory with "server-cert.pem" # and "server-key.pem" in it before running this! my $daemon = new HTTP::Daemon::SSL SSL_key_file => '(takenout)server-key.pem', SSL_cert_file => '(takenout)server-cert.pem', LocalPort => 8080; my $soap = SOAP::Transport::HTTP::Server -> new ( ) -> dispatch_to('TTPSubmit'); print "Please contact me at: <URL:", $daemon->url, ">\n"; while (my $conn = $daemon->accept()) { while (my $request = $conn->get_request()) { $soap->request($request); $soap->handle(); my $response = $soap->response(); $conn->send_response($response); } $conn->close; undef($conn); } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://705367]
Approved by NetWallah
Front-paged by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-03-28 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found