Windows Server 2019 Build 17677 - Issue with Named Pipes

%3CLINGO-SUB%20id%3D%22lingo-sub-202298%22%20slang%3D%22en-US%22%3EWindows%20Server%202019%20Build%2017677%20-%20Issue%20with%20Named%20Pipes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-202298%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3EDescription%20of%20the%20issue%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20installed%20LTSC%20Build%2017677%2C%20Datacenter%20Edition%2C%20on%20two%20nodes.%26nbsp%3B%20I've%20seen%20something%20weird%20with%20Named%20Pipes%20communication%20that%20I'd%20like%20to%20report.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20my%20scenario%2C%20I%20the%20two%26nbsp%3Bsystems%26nbsp%3Bare%20named%20NODE1%20and%20NODE2.%26nbsp%3B%20I've%20got%20simple%20Powershell%20scripts%20that%20implement%20a%20named%20pipe%20server%20and%20client.%20These%20are%20included%20below.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20run%20the%20server%20on%20NODE2%20using%20this%20command%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E.%5CNamedPipeServer.ps1%20Test%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20it%26nbsp%3Bcreates%20the%20pipe%2C%20waits%20for%20a%20connection%2C%20prints%20a%20message%2C%20disconnects%2C%20then%20repeats.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOn%20NODE1%2C%20I%20run%20this%20command%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E.%5CNamedPipeClient.ps1%20NODE2%20Test%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20client%20on%20NODE1%20opens%20a%20client%20pipe%20using%20the%20server%20hostname%20and%20pipe%20name%2C%20connects%20to%20it%2C%20then%20closes%20the%20pipe%20and%20repeats%20every%205%20seconds.%26nbsp%3B%20Please%20see%20the%20attached%20scripts%20for%20details.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20reboot%20NODE2%20while%20NODE1%20is%20running%20the%20client%20script%2C%20as%20expected%20I%20see%20that%20connections%20fail.%26nbsp%3B%20However%2C%20when%20NODE2%20comes%20back%20up%2C%20I%20can%20login%20and%20restart%20the%20server%20script.%26nbsp%3B%20However%2C%20it%20never%20re-establishes%20a%20connection%20-%20the%20client%20continues%20to%20report%20that%20the%20connect%20attempt%20failed.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20are%20two%20ways%20I%20can%20get%20communication%20to%20start%20again.%3C%2FP%3E%3COL%3E%3CLI%3Estop%20the%20client%20script%20for%2010%20seconds.%26nbsp%3B%20Then%20restart%20it%20-%20it%20will%20connect%20immediately.%3C%2FLI%3E%3CLI%3Eopen%20a%20share%20on%20NODE2%20from%20NODE1%20(i.e.%20%22dir%20%5C%5CNODE2%5Cc%24%22).%26nbsp%3B%20The%20next%20client%20connect%20attempt%20will%20succeed.%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%3CSTRONG%3EIt%20seems%20like%20something%20in%20the%20client%20Named%20Pipe%20logic%20is%20caching%20the%20connection%20result%2C%20and%20not%20retrying%20the%20connection%20to%20the%20host%20if%20it%20sees%20that%20the%20previous%20attempt%20failed%20less%20than%2010%20seconds%20ago.%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CU%3E%3CSTRONG%3EScripts%20for%20reproducing%20the%20issue%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20following%20scripts%20are%20what%20I%20used%20to%20reproduce%20this.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CU%3ENamedPipeServer.ps1%3C%2FU%3E%3C%2FP%3E%3CP%3Eif(%24args%5B0%5D%20-eq%20%24null)%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20'Must%20specify%20a%20pipe%20name%20to%20create'%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20exit%201%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Ewhile(%24true)%20%7B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%24npipeServer%20%3D%20new-object%20System.IO.Pipes.NamedPipeServerStream(%24args%5B0%5D%2C%20%5BSystem.IO.Pipes.PipeDirection%5D%3A%3AInOut)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20'Waiting%20for%20connection'%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%24npipeServer.WaitForConnection()%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%22Got%20connection%20%24%3F%22%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%24npipeServer.Close()%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CU%3ENamedPipeClient.ps1%3C%2FU%3E%3C%2FP%3E%3CP%3Eif(%24args%5B0%5D%20-eq%20%24null)%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20'Specify%20a%20server%20name%20as%20the%20first%20argument'%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20exit%201%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Eif(%24args%5B1%5D%20-eq%20%24null)%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20'Specify%20a%20pipe%20name%20as%20the%20second%20argument'%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20exit%201%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Ewhile(%24true)%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%24npipeClient%20%3D%20new-object%20System.IO.Pipes.NamedPipeClientStream(%24args%5B0%5D%2C%20%24args%5B1%5D%2C%20%5BSystem.IO.Pipes.PipeDirection%5D%3A%3AInOut%2C%20%5BSystem.IO.Pipes.PipeOptions%5D%3A%3ANone%2C%20%5BSystem.Security.Principal.TokenImpersonationLevel%5D%3A%3AImpersonation)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%24npipeClient.Connect(3000)%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%22Connected%20%24%3F%22%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20Get-Date%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%24npipeClient.Close()%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20Start-Sleep%205%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-202298%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ENetworking%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Frequent Visitor

Description of the issue

 

I've installed LTSC Build 17677, Datacenter Edition, on two nodes.  I've seen something weird with Named Pipes communication that I'd like to report.

 

In my scenario, I the two systems are named NODE1 and NODE2.  I've got simple Powershell scripts that implement a named pipe server and client. These are included below.

 

I run the server on NODE2 using this command:

 

.\NamedPipeServer.ps1 Test

 

and it creates the pipe, waits for a connection, prints a message, disconnects, then repeats. 

 

On NODE1, I run this command:

 

.\NamedPipeClient.ps1 NODE2 Test

 

The client on NODE1 opens a client pipe using the server hostname and pipe name, connects to it, then closes the pipe and repeats every 5 seconds.  Please see the attached scripts for details.

 

If I reboot NODE2 while NODE1 is running the client script, as expected I see that connections fail.  However, when NODE2 comes back up, I can login and restart the server script.  However, it never re-establishes a connection - the client continues to report that the connect attempt failed.

 

There are two ways I can get communication to start again.

  1. stop the client script for 10 seconds.  Then restart it - it will connect immediately.
  2. open a share on NODE2 from NODE1 (i.e. "dir \\NODE2\c$").  The next client connect attempt will succeed.

It seems like something in the client Named Pipe logic is caching the connection result, and not retrying the connection to the host if it sees that the previous attempt failed less than 10 seconds ago.

 

Scripts for reproducing the issue

 

The following scripts are what I used to reproduce this.

 

NamedPipeServer.ps1

if($args[0] -eq $null) {
    'Must specify a pipe name to create'
    exit 1
}

while($true) {

    $npipeServer = new-object System.IO.Pipes.NamedPipeServerStream($args[0], [System.IO.Pipes.PipeDirection]::InOut)

    'Waiting for connection'
    $npipeServer.WaitForConnection()

    "Got connection $?"
    $npipeServer.Close()
}

 

NamedPipeClient.ps1

if($args[0] -eq $null) {
    'Specify a server name as the first argument'
    exit 1
}

if($args[1] -eq $null) {
    'Specify a pipe name as the second argument'
    exit 1
}

while($true) {
    $npipeClient = new-object System.IO.Pipes.NamedPipeClientStream($args[0], $args[1], [System.IO.Pipes.PipeDirection]::InOut, [System.IO.Pipes.PipeOptions]::None, [System.Security.Principal.TokenImpersonationLevel]::Impersonation)

    $npipeClient.Connect(3000)
    "Connected $?"
    Get-Date

    $npipeClient.Close()
    Start-Sleep 5
}

 

 

0 Replies