Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetTcpBinding repeated connections and disconnections with ReliableSession: Close() on channel sometimes takes a long time #4746

Closed
DareDevilDenis opened this issue Oct 16, 2021 · 8 comments · Fixed by #4752
Assignees
Milestone

Comments

@DareDevilDenis
Copy link

Describe the bug
I have a WCF NetTcpBinding server (.NET framework 4.8) that has a binding that uses ReliableSession. I have a WCF client running on the same PC that repeatedly (in a loop 5000 times) creates a channel, calls a WCF API method on the server, and closes the channel (this configuration is used to demonstrate the problem). Using a .NET 5.0 WCF client (version 4.9.0-rc2.21473.1 of System.ServiceModel.Primitives, System.ServiceModel.NetTcp, System.ServiceModel.Duplex)

Each call to:

((ICommunicationObject)channel).Close();

is usually fast (less than 1ms), however sometimes Close() gets stuck for 1 minute (the default value for CloseTimeout). This can be seen in the output of the attached solution (which runs in a loop 5000 times):

<snip>
2021-10-15 10:43:42.103 Calling Ping 1319
2021-10-15 10:43:42.104 Ping result: True
2021-10-15 10:43:42.104 Calling Close on channel
2021-10-15 10:43:42.105 Channel closed
2021-10-15 10:43:42.105 Creating channel
2021-10-15 10:43:42.105 Created Channel
2021-10-15 10:43:42.105 Calling Ping 1320
2021-10-15 10:43:42.107 Ping result: True
2021-10-15 10:43:42.107 Calling Close on channel
2021-10-15 10:44:42.116 Channel closed   <-------------- DELAY OF 1 MINUTE
2021-10-15 10:44:42.116 Creating channel
2021-10-15 10:44:42.117 Created Channel
2021-10-15 10:44:42.117 Calling Ping 1321
2021-10-15 10:44:42.125 Ping result: True
2021-10-15 10:44:42.125 Calling Close on channel
2021-10-15 10:44:42.127 Channel closed
<snip>

In my run of 5000 iterations on Win10 this 1 minute delay happened 4 times.

Using a .NET Framework 4.8 WCF client with exactly the same code it works fine.
If I turn off ReliableSession then the .NET 5.0 client works fine.

To Reproduce
Run the attached sample project on a single Windows PC: WcfClientServerPings.zip

Command window 1:

  cd WcfServer\bin\Debug
  WcfServer.exe

Command window 2:

  cd WcfClientDotNetCore\bin\Debug\net5.0
  WcfClientDotNetCore.exe

Note: The client and server are hardcoded to talk on port 5156. If this port is in use on your PC just change 'const int port' on both the client and server.

Expected behavior
Since both the client and server are running on the same PC there should be no big delay when calling Close().

Additional notes
I originally raised issue #4734 when using version 4.8.1 of the System.ServiceModel DLLs. I was advised to move to 'RC2' and that's when I encountered this new issue.

@mconnew
Copy link
Member

mconnew commented Oct 21, 2021

@DareDevilDenis, good news, I found the problem and this will be in the RTM release. Having the repro app really helped. Thank you.

@DareDevilDenis
Copy link
Author

You're welcome @mconnew. I know this is probably not the right place to ask, but do you or @HongGit have an estimate of when the RTM release will be made?
Nice Nirvana T-shirt by the way :)

@mconnew
Copy link
Member

mconnew commented Oct 26, 2021

Our RTM build is released at the same time as .NET 6 goes RTM. It's been announced that .NET 6 will be release during .NET Conf which is November 9 - 11.

@DareDevilDenis
Copy link
Author

Thanks :)

@DareDevilDenis
Copy link
Author

Hi @mconnew. I have a couple of dumb questions (apologies in advance!). The second one is off topic for this thread but I didn't think it was worth raising as a separate issue.

Question 1
Is there an easy way for me to verify this fix before the RTM release? I built the project as instructed at https://github.com/dotnet/wcf/blob/main/Documentation/developer-guide.md but after building I didn't know what to do next! I couldn't find any nuget packages for System.ServiceModel.Primitives, System.ServiceModel.NetTcp, System.ServiceModel.Duplex.

Question 2
What is the reasoning behind releasing this project at the same time as .NET 6? Am I correct in understanding that .NET 6 does not actually include this project? I found an old comment from you: #1655 (comment)

I just committed the reliable sessions implementation. While this is shipping as part of the overall .NET 5 release, WCF continues to only depend on netstandard2.0 so new features are enabled for all supported versions of .NET Core and you do not need to move to .NET 5 to use these new features.

So I guess that means that the upcoming wcf release in November can be used with .NET 5 and .NET 6, right?

@onefreddy
Copy link

any news?

@mconnew
Copy link
Member

mconnew commented Jul 15, 2022

@onefreddy, news about what? We shipped a fix for this issue last year. You need to be using the latest package versions.

@Shruthi1984
Copy link

I dont see this issue being fixed i m using .NET 6.0 , but i still see the same issue reported here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants