Hello Alessandro
The two ways you mentioned I have tried.But it doesn't work yet.
Yes,It's 4 sure only on Unix.But I haven't tried MINA 1.0 cause the
ex-server built on MINA 0.9.4 is running public,which cannot be stopped by
will.
I will try later
Best Wishes
James Ling
----- Original Message -----
From: "Alessandro Torrisi" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, October 17, 2006 3:55 PM
Subject: Re: Question About Port Stucking(It has troubled me 4 a very long
term)
I have this problem only on Unix machines (Linux and MacOsX)...
I added this code for shutdown, tonight I will try also to explicitly
close
all the sessions (now I don't have a linux machine to try it)...
// shutdown bug on unix machines (found on linux / mac os x)
Runtime.getRuntime().addShutdownHook(new Thread() {
// This method is called during shutdown
@Override
public void run() {
socketAcceptor.unbindAll();
System.exit(0);
}
});
So i will add this few lines:
@SuppressWarnings("unchecked")
Set<IoSession> sessions = socketAcceptor.getManagedSessions
(serverAddress);
for (IoSession session : sessions) {
session.close();
}
the complete code:
// shutdown bug on unix machines (found on linux / mac os x)
Runtime.getRuntime().addShutdownHook(new Thread() {
// This method is called during shutdown
@Override
public void run() {
socketAcceptor.unbindAll();
@SuppressWarnings("unchecked")
Set<IoSession> sessions = socketAcceptor.getManagedSessions
(serverAddress);
for (IoSession session : sessions) {
session.close();
}
System.exit(0);
}
});
On 10/17/06, 凌晨 <[EMAIL PROTECTED]> wrote:
----- Original Message -----
From: "凌晨" <[EMAIL PROTECTED]>
To: "Hieu Phan Thanh" <[EMAIL PROTECTED]>
Sent: Tuesday, October 17, 2006 3:13 PM
Subject: Re: A Question About Port Stucking
> Hello,
> Unfortunately,I have already invoke the unbindAll() method,which is
> still useless :( (I did even recycle all the connections by invoking
every
> IoSession's close())
> It's A MINA's BUG I dare to say cause other Open Source Projects like
> MINA,take QuickServer 4 example,which doesn't possess this problem.
> So what I supposed to do when the server is hung?I just cann't restart
the
> server immediately,which is very important.
> Thanks for your kind reply.
> Best wishes,
> James Ling
> ----- Original Message -----
> From: "Hieu Phan Thanh" <[EMAIL PROTECTED]>
> To: "??" <[EMAIL PROTECTED]>
> Sent: Tuesday, October 17, 2006 2:46 PM
> Subject: RE: A Question About Port Stucking
>
>
> Hello,
>
> I used to encounter this problem before. I don't know how to fix too.
> I think that the "setReuseAddress()" is not worked in inter-process.
>
> The process 1 is listening on Port1 => kill this process 1 => the Port1
> still has not released yet.
> So the process 2 could not listen on that port due to "Address already
in
> use".
>
> I think that we have to release the requested resource ("unbind" the
> listening port). MINA has support us to do that.
>
> Hope I could help u something.
>
> Thanks & best regards,
> Hieu Phan.
>
> ________________________________________
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 16, 2006 4:33 PM
> To: Hieu Phan Thanh
> Subject: A Question About Port Stucking
>
> Dear Phan Thanh:
> Sorry to bother you.A server was biult on MINA0.9.4,JDK1.5,which is
> running on Linux system(red hat).When the server listening on port to
> accept connections
> that come from WAN.After some time,when there are almost connections
> established to this server,I stop the server using "kill" command,then
> I
> find there are many connections still bound to
> the port.So if I restart the server there will be a "address already in
> use" exception thrown.I check the port use "netstat" command then to
find
> many conneciton in "TIME_WAIT" ,"FIN_WAIT1" AND "FIN_WAIT2"
> state.
> The reuseaddr option of the server is enabled by
> ((SocketAcceptorConfig)
> config).setReuseAddress(true);
> And Every incoming connection I also so the same thing
> ((SocketSessionConfig) session.getConfig()).setReuseAddress(true);
> But It still does't work.
> Have you ever happen to meet this situation?
> Thanks In advance!
>
--
Alessandro Torrisi
Information Technology Consultant
[EMAIL PROTECTED]
"Questo documento è formato esclusivamente per il destinatario. Tutte le
informazioni ivi contenute, compresi eventuali allegati, sono soggette a
riservatezza a termini del vigente D.Lgs. 196/2003 in materia di "privacy"
e
quindi ne è proibita l'utilizzazione. Se avete ricevuto per errore questo
messaggio, Vi preghiamo cortesemente di contattare immediatamente il
mittente e cancellare la e-mail. Grazie."