commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Renouf <eren...@skaion.com>
Subject Re: daemon issue
Date Tue, 04 Jan 2005 16:08:04 GMT
Quoting Wade Chandler <wchandler@redesetgrow.com>:

> Eric Renouf wrote:
> > Quoting Wade Chandler <wchandler@redesetgrow.com>:
> > 
> > 
> >>Eric Renouf wrote:
> >>
> >>>Hi Wade,
> >>>
> >>>Yes it is able to create the ServerSocket in a Thread spawned from the
> >>
> >>start()
> >>
> >>>method.  That socket is able to listen to incoming connections and spawn
> a
> >>
> >>new
> >>
> >>>thread to handle each incoming connection.  I added a test inside that
> >>
> >>thread
> >>
> >>>that handles the connections to create a socket to a remote host on port
> 80
> >>
> >>and
> >>
> >>>that succeeds.  The handler thread then processes the input and one
> >>
> >>possible
> >>
> >>>action for it is to start a new thread that will use HttpClient to "surf"
> >>
> >>the
> >>
> >>>web.  The surfing thread seems unable to create sockets though.  The
> >>
> >>HttpClient
> >>
> >>>raises a java.net.ConnectException, as does just trying to create a new
> >>
> >>socket
> >>
> >>>on port 80 similar to the one that succeeded previously in the handler
> >>
> >>thread.
> >>
> >>>Oh yeah, in case it makes a difference to anyone here's some of the stuff
> >>
> >>I'm
> >>
> >>>using to run it:
> >>>
> >>>JDK 1.5.0
> >>>RedHat 7.3 with kernel 2.4.20
> >>>commons-daemon-1.0
> >>>
> >>>Thanks,
> >>>Eric
> >>>
> >>>Quoting Wade Chandler <wchandler@redesetgrow.com>:
> >>>
> >>>
> >>>
> >>>>Eric Renouf wrote:
> >>>>
> >>>>
> >>>>>Hi all,
> >>>>>
> >>>>>I'm trying to write a Java Daemon which will listen for incoming
> >>>>
> >>>>connections and
> >>>>
> >>>>
> >>>>>when it gets certain commands start up various threads or processes.

> The
> >>>>>problem that I'm having right now involves the spawned threads creating
> >>>>
> >>>>sockets.
> >>>>
> >>>>
> >>>>>When running via jsvc as a daemon the main listening thread spawns
a
> >>
> >>thread
> >>
> >>>>to
> >>>>
> >>>>
> >>>>>handle each connection.  That thread is able to create a new
> Socket(host,
> >>>>
> >>>>port)
> >>>>
> >>>>
> >>>>>with no problem (just added for testing purposes).  That thread the
> >>>>
> >>>>processes
> >>>>
> >>>>
> >>>>>the command and, in some cases, spawns a new thread that uses the
> >>>>
> >>>>HttpClient
> >>>>
> >>>>
> >>>>>package to retrieve a web page, but that failes with a
> >>>>
> >>>>java.net.ConnectException
> >>>>
> >>>>
> >>>>>connection failed.  If I just try to do the same Socket(host, port)
as
> >>
> >>the
> >>
> >>>>>listening thread does that also fails.
> >>>>>
> >>>>>Also if I run the whole thing by hand, not as a Daemon everything
seems
> >>
> >>to
> >>
> >>>>work
> >>>>
> >>>>
> >>>>>just fine.
> >>>>>
> >>>>>Can anyone help point out something that I could be overlooking,
> because
> >>>>
> >>>>I'm not
> >>>>
> >>>>
> >>>>>sure what else to try as far as tracking this down goes.
> >>>>>
> >>>>>Thanks,
> >>>>>Eric
> >>>>>___________________________________________________________
> >>>>>This mail sent using ToadMail -- Web based e-mail @ ToadNet
> >>>>>
> >>>>>---------------------------------------------------------------------
> >>>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>Do you have any logging to see if your process is actually binding to

> >>>>the server port fine?  Maybe log that, and in the main setup code try
to
> 
> >>>>make a socket connection to test your server before you continue on and

> >>>>debug that section of code.
> >>>>
> >>>>Wade
> >>>>
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>>>
> >>>
> >>>
> >>>
> >>>
> >>>___________________________________________________________
> >>>This mail sent using ToadMail -- Web based e-mail @ ToadNet
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>>
> >>>
> >>>
> >>
> >>Just for checkking.....you aren't trying to use some type of a global 
> >>object for the HttpClient are you?  Figure you'd at least get a 
> >>different error though.  hmm.  seems strange.  The server on port 
> >>80...is it a well known server like Apache or something, or is it 
> >>another program you have written.  If so are you sure it is able to 
> >>handle multiple connections correctly?  I would say that maybe there is 
> >>a bug in the 1.5 jdk, but I have used it to make connections...not using 
> >>HttpClient, but the standard URLConnection classes.  Did you get a stack 
> >>trace?  While the other application isn't able to make connections to 
> >>the remote servers port 80 are other applications from the same computer 
> >>able to connect to that servers port 80?
> >>
> >>Wade
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>
> > 
> > 
> > The HttpClient objects aren't global, nor do the objects they instantiate
> have
> > any global fields/methods.  As a possibly interesting aside to all this, it
> is
> > able to create a JDBC connection to a Postgresql database (running locally)
> and
> > that seems to work OK from the same instance(s) that is able to create the
> > remote sockets.
> > 
> > It's an Apache server that I'm connecting to.  As for other applications
> being
> > able to make the connection I'm able to telnet to that host on port 80. 
> Also 
> > the same code is able to make the connection if I don't run it under jsvc,
> but
> > start it with java directly.
> > 
> > Here's a stack trace:
> > java.net.ConnectException: errno: 0, error: connect failed
> >                                                                            
>    
> >                                                 
> >         at java.net.PlainSocketImpl.socketConnect(Native Method)
> >         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
> >         at
> java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
> >         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
> >         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
> >         at java.net.Socket.connect(Socket.java:507)
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >         at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >         at java.lang.reflect.Method.invoke(Method.java:585)
> >         at
> >
>
org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:139)
> >         at
> >
>
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:124)
> >         at
> > org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:705)
> >         at
> >
>
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1339)
> >         at
> >
>
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:359)
> >         at
> >
>
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:168)
> >         at
> >
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:393)
> >         at
> >
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
> >         at com.skaion.TG.bots.HttpBot.browse(HttpBot.java:240)
> >         at com.skaion.TG.bots.HttpBot.browse(HttpBot.java:222)
> >         at com.skaion.TG.bots.HttpBot.nextPage(HttpBot.java:197)
> >         at com.skaion.TG.bots.HttpBot.run(HttpBot.java:569)
> >         at com.skaion.TG.Service.<init>(Service.java:69)
> >         at
> com.skaion.TG.SlaveServer$ConnectionHandler.run(SlaveServer.java:399)
> > 
> > Eric
> > 
> > ___________________________________________________________
> > This mail sent using ToadMail -- Web based e-mail @ ToadNet
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> > 
> > 
> > 
> 
> Man Eric,
> 
> I would dump all of my configuration information for the 
> client...server, port, proto, everything....then I would compare it all 
> to some code I know is working.  Barring that....I would ask around on 
> the jre/jdk lists and see if anyone else is having this problem.  Also I 
> would check the bug database at:
> http://bugs.sun.com/bugdatabase/index.jsp
> 
> Unless something is misconfigured...or just not set exactly right...I 
> would say there is a bug or something getting you.  My guess is it's 
> something you're over looking that is hard to convey here, but that 
> might be entirely wrong.  It may very well be a bug considering your 
> making the connections from threads.  Could be something going on with a 
> lib or something.
> 
> Wade
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 

Well thanks for your time and help Wade.  I have a work around that instead of
daemonizing through the jsvc I wrote a PERL wrapper that daemonizes and then
exec to launch the jvm and that seems to work well enough, so for now I guess
I'll just go with that.  Thanks again for your time though.

Eric

___________________________________________________________
This mail sent using ToadMail -- Web based e-mail @ ToadNet

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message