0

I am on Windows Server 2016 Standard. See netstat output below (IP replaced):

C:\Users\user>netstat -an|findstr "55559"
  TCP    1.2.3.4:55559     1.2.3.4:55559     ESTABLISHED

What does it mean? I was searching the Net for answers but found nothing. Can somebody explain?

UPDATE:

  1. Process1 was listening on port 55559.
  2. Process2 connected to it from the same machine (but on its public IP: 10.x.y.z).

(Process1 is an IIS AppPool, which besides its normal OWIN WebApi interface opens an additional tcp service socket on port 55559 for internal purposes.)

  1. Process1 was terminated by IIS resource management features (not used for a "long time").

The result is the situation described in the question.

The problem is: Process1 cannot be restarted (on first request by IIS), because its initialization fails (cannot bind on port 55559 because another process uses it.)

The another process is: Process2! Why? How?

9
  • As a first step run netstat with the -abon switches so you can see which process and executable are responsible for this connection. You can also try to check with Sysinternals TCPView (learn.microsoft.com/en-us/sysinternals/downloads/tcpview). Commented Dec 14, 2022 at 14:45
  • 1.2.3.4 doesn't happen to 127.x.y.z does it? Commented Dec 14, 2022 at 16:05
  • @YisroelTech The process (X) is known. Another process (Y) listened on port 55559 and X supposed to connect to it. Exit of process Y resulted in the mentioned situation.
    – cly
    Commented Dec 14, 2022 at 16:12
  • 1
    can you disconnect the extra TCP session using the globals.asax application_stop event? that seems like it would be the proper solution. Commented Dec 14, 2022 at 18:03
  • 1
    see if this alternative to globals.asax works for you: stackoverflow.com/questions/35705830/… Commented Dec 14, 2022 at 18:50

1 Answer 1

0

For reference here is the solution I mentioned in comments.

During app init phase call the RegisterForDisposal method below. It will register a method to be called on exit.

Then add your code to the registered method to be executed on exit.

// call this method during startup where you have IAppBuilder reference
private void RegisterForDisposal(IAppBuilder app)
{
   string key = "host.OnAppDisposing";
   if (app.Properties.ContainsKey(key))
   {
      if (app.Properties[key] is CancellationToken token)
      {
         if (token != CancellationToken.None)
         {
            // this registers the Stop method below 
            // to be executed on exit
            token.Register(this.Stop);
         }
      }
   }
}

public void Stop()
{
   // do want you want on stop
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .