You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After the NetTcp channel is opened you start using it. Then it seams like the channel is closed by the client if a call is in progress when the timeout, set in OpenTimeout, expires from the time you CreateChannel. This happens independent of the setting of the RecieveTimeout, SendTimeout and CloseTimeout.
This issue is new since System.ServiceModel.NetTcp Version 4.10.2
When using WireShark I can see that the client sends [RST,ACK] (close).
Reproduction: Below a working sample of console app with both server and client.
Program.cs
usingCoreWCF;usingCoreWCF.Configuration;usingMicrosoft.AspNetCore.Builder;usingSystem.Diagnostics;internalclassProgram{publicstaticasyncTaskMain(){intport=50000;stringbaseAddress=$"net.tcp://localhost:{port}";stringserviceAddress=$"{baseAddress}/EchoService";stringtestString=newstring('a',3000);varbuilder=WebApplication.CreateBuilder();builder.WebHost.UseNetTcp(port);builder.Services.AddServiceModelServices();varapp=builder.Build();app.UseServiceModel(serviceBuilder =>{serviceBuilder.AddService<EchoService>();varbinding=newNetTcpBinding();serviceBuilder.AddServiceEndpoint(typeof(EchoService),typeof(IEchoService),binding,newUri(serviceAddress),newUri(baseAddress));});awaitapp.StartAsync();varbinding=newSystem.ServiceModel.NetTcpBinding{OpenTimeout=TimeSpan.FromSeconds(10),// make sure they dont interfere the testReceiveTimeout=TimeSpan.FromMinutes(15),SendTimeout=TimeSpan.FromMinutes(15),CloseTimeout=TimeSpan.FromMinutes(15),};varfactory=newSystem.ServiceModel.ChannelFactory<IEchoService>(binding,newSystem.ServiceModel.EndpointAddress(newUri(serviceAddress)));varchannel=factory.CreateChannel();vardt=DateTime.Now;System.ServiceModel.Channels.IChannelichannel=(System.ServiceModel.Channels.IChannel)channel;ichannel.Open();varresult1=awaitchannel.EchoString(testString);// this worksvarresult2=awaitchannel.EchoString(testString);// this throws System.ServiceModel.CommunicationException}}[CoreWCF.ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Multiple,InstanceContextMode=InstanceContextMode.Single)]publicclassEchoService:IEchoService{publicasyncTask<string>EchoString(stringecho){awaitTask.Delay(TimeSpan.FromSeconds(6));returnecho;}}[System.ServiceModel.ServiceContract]publicinterfaceIEchoService{[System.ServiceModel.OperationContract]Task<string>EchoString(stringecho);}
.csproj file:
<ProjectSdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<FrameworkReferenceInclude="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReferenceInclude="CoreWCF.ConfigurationManager"Version="1.4.0-preview1" />
<PackageReferenceInclude="System.ServiceModel.NetTcp"Version="6.0.0-rc.23205.4" />
<!-- Works with this version --><!--<PackageReference Include="System.ServiceModel.NetTcp" Version="4.10.2" />-->
</ItemGroup>
</Project>
The text was updated successfully, but these errors were encountered:
I found the problem. SocketConnection.OnReceiveTimeout isn't checking _receiveTimerEnabled. Creating and removing timers is expensive, so when we want to cancel the timer, we just set _receiveTimerEnabled to false. Without that check, when the timer fires after being "cancelled" it's closing the connection as though we've actually timed out. There's the same problem on the send timer.
After the NetTcp channel is opened you start using it. Then it seams like the channel is closed by the client if a call is in progress when the timeout, set in OpenTimeout, expires from the time you CreateChannel. This happens independent of the setting of the RecieveTimeout, SendTimeout and CloseTimeout.
This issue is new since System.ServiceModel.NetTcp Version 4.10.2
When using WireShark I can see that the client sends [RST,ACK] (close).
Reproduction: Below a working sample of console app with both server and client.
Program.cs
.csproj file:
The text was updated successfully, but these errors were encountered: