commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wade Chandler <wchand...@redesetgrow.com>
Subject Re: daemon issue
Date Tue, 04 Jan 2005 14:38:19 GMT
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


Mime
View raw message