1748270 Members
3903 Online
108760 Solutions
New Discussion юеВ

Reset / reclaim port

 
yulianto piyut
Valued Contributor

Reset / reclaim port

all,

I have an application running on my server rp4440, run hp-ux 11.11 with port 5501. The application is become hang and cannot be shutdown and kill.

# netstat -an |grep 5501
tcp 0 0 10.2.245.13.63151 10.2.224.49.5501 FIN_WAIT_2
55013540 stream 0 0 0 5b5de9c0 0 0
550139c0 stream 0 0 0 54e14680 0 0
55013b40 stream 0 0 0 54e14600 0 0 /tmp/.AgentSockets/A
# lsof -i:5501
#

how to reset this port ? should i reboot my server ?
13 REPLIES 13
V. Nyga
Honored Contributor

Re: Reset / reclaim port

Hi,

reboot is always a clean solution.
You also can try to change boot level to 'init 2' or 'init 1', then go back to 'init 3'.

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
yulianto piyut
Valued Contributor

Re: Reset / reclaim port

oo...only reboot server to reset the port ? hmm...not good for my production server.
Matti_Kurkela
Honored Contributor

Re: Reset / reclaim port

Your socket is in FIN_WAIT_2 state and the process associated with the socket has already died. This means the socket is in "detached" state.

With default settings, the solution should be simple: just wait 2 minutes. The system should automatically remove this socket in that time.

This behaviour is controlled by the ndd parameter "tcp_keepalive_detached_interval". To check it, run:

ndd -get /dev/tcp tcp_keepalive_detached_interval

The default value for this parameter is 120000, which means 120 seconds (=2 minutes).

If the socket does not go away and/or your tcp_keepalive_detached_interval is currently set to an unreasonably long time, you might use the attached Perl script. It will use an *unsupported* ndd parameter "tcp_discon_by_addr" to force disconnect *all* connections that are currently in state FIN_WAIT_2. It was originally created for HP-UX 11.00, but should work on 11.11 too.

MK
MK
yulianto piyut
Valued Contributor

Re: Reset / reclaim port

hi matti, how to use tcp_discon_by_addr?
the port state of 5501 still FIN_WAIT_2. it's happened for about 1 month ago.
Matti_Kurkela
Honored Contributor

Re: Reset / reclaim port

The easiest way would be to just run the script I attached: it does not require any parameters.

To use tcp_discon_by_addr directly, you would have to convert the local IP address, local port number, remote IP address and remote port number to hexadecimal and concatenate all of them together in this order. (always 2 hex digits for each part of an IP address, and always 4 hex digits for the port number; add leading zeroes if necessary)

For your specific case, the command line would be:

ndd -set /dev/tcp tcp_discon_by_addr 0a02f50df6af0a02e031157d

The conversion:
10.2.245.13 = 0a 02 f5 0d
63151 = f6af
10.2.224.49 = 0a 02 e0 31
5501 = 157d

(I was hoping I would not have to do this conversion by hand by providing the script. Oh well, slow day... :-)

MK
MK
yulianto piyut
Valued Contributor

Re: Reset / reclaim port

hi, after i run script in your attachment:

# netstat -an |grep 5501
tcp 0 0 10.2.245.13.1556 10.2.245.13.55010 ESTABLISHED
tcp 0 0 10.2.245.13.55010 10.2.245.13.1556 ESTABLISHED
550139c0 stream 0 0 0 54e14680 0 0
55013b40 stream 0 0 0 54e14600 0 0 /tmp/.AgentSockets/A

hmm...i'm confuse, how to use port 5501 again ?
V. Nyga
Honored Contributor

Re: Reset / reclaim port

Hi,

not all ports are used every time.
The port will be used again after restart of your application.

Volkmar
*** Say 'Thanks' with Kudos ***
yulianto piyut
Valued Contributor

Re: Reset / reclaim port

hi nyga,

the applicaiton cannot be killed or shutdown and port 5501 is used for it.
V. Nyga
Honored Contributor

Re: Reset / reclaim port

Hi again,

yes, but you says it's hanging ....
so it can't (and don't need to) use the port now.
It seems like you have to investigate how to stop the application.
Have you tried 'kill -9 '?
Any error message?

What kind of application?
Have you tried to kill the parent process?

Volkmar
*** Say 'Thanks' with Kudos ***