"TIME_WAIT" is something the tcp/ip stack does; it doesn't have anything
to do with Tomcat per say.  What happens (as I understand it) is that once 
your app has closed the connection (page is done or whatever), the stack 
will hold the connection in a "TIME_WAIT" state to prevent the other end, 
the client, from reconnecting to the same port.  

So the problem isn't really tomcat, its the TCP/IP stack.  However I've
also found that under unix if you're using apache+tomcat you don't have a
ton of TIME_WAIT sockets on the webserver.  Apache apparently sets a 
parameter to eliminate the TIME_WAIT sockets, either on close or on open
of the socket (I don't know which).  So what you might want to do is run
IIS or Apache in front of tomcat.  I don't know that IIS does the same
thing as Apache in regards to the sockets, but if it does then it'll work
nearly as well in front of tomcat.  But there is a slight problem here
as well, you need to be sure that you're using APJ13 not APJ12 as APJ12
will open a new connection for each web access that tomcat handles.  And
in that casey you'd get more TIME_WAIT sockets.  APJ13 multiplexes the 
requests over one persistent socket, so you don't have the extra overhead
of opening the socket on each request, or the TIME_WAIT socket lingering
there for some time period.

Also, just as a FYI, under unix you can change the TIME_WAIT time period 
but it's not recommended that you do so.  The default time period is about 
4 minutes as I recall.  You can probably also change it under windows, but 
I wouldn't have a clue how to do that.

--mikej
-=-----
mike jackson
[EMAIL PROTECTED] 

> -----Original Message-----
> From: Taral Shah [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 16, 2002 2:40 AM
> To: Tomcat Users List
> Subject: Persistent Connection
> 
> 
> I am using tomcat 3.3
> 
> Now I am calling one jsp which loads an applet, internally that 
> applet uses
> url connection to fetch data.
> Now problem is that when i check with netstat application(its 
> inbuilt in win
> nt, run through netstat -n)
> I came to know tomcat opens no of connections and keep them in TIME_WAIT
> mode.
> 
> This is happening with simple jsps as well as with servlet. For 
> each request
> it opens around 2/3(depending on the no of jsps included) connection with
> <host-ip>:8080 port. These all are of tcp type connections.
> I read in some of materials that in Http 1.1, as persistent connection is
> used so it keeps the connection open unless I specify them to close.
> 
> I wrote in my code as response.setHeader("Connection", "close");
> but still the no of open connection increases. In my application 
> if hits are
> many then it reaches to thousands.
> 
> Has any one seen this before(I think this is for all tomcat-You can check
> with netstat).
> Has any one explicitly closed the connection through header or is 
> there any
> way to specify in tocat configuration so it does not keep the connection
> open.
> 
> Thanks
> 
> Taral Shah
> Experience is what you get when you were expecting something else.
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 
> 


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to