Skip to content

Commit af275d1

Browse files
afifi-insmconnew
authored andcommitted
fix bug and add unit test
1 parent 0246e76 commit af275d1

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/System.Private.ServiceModel/tests/Scenarios/Binding/Tcp/NetTcpBindingTests.4.0.0.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,42 @@ public static void ReceiveTimeout_Applied()
118118
ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory);
119119
}
120120
}
121+
122+
// Test for https://github.com/CoreWCF/CoreWCF/issues/1391
123+
[WcfFact]
124+
[OuterLoop]
125+
public static void SecurityModeNone_Echo_RoundTrips_String_Stream_TimeoutMaxValue()
126+
{
127+
string testString = "Hello";
128+
ChannelFactory<IWcfServiceGenerated> factory = null;
129+
IWcfServiceGenerated serviceProxy = null;
130+
131+
try
132+
{
133+
// *** SETUP *** \\
134+
var binding = new NetTcpBinding(SecurityMode.None)
135+
{
136+
SendTimeout = TimeSpan.MaxValue,
137+
ReceiveTimeout = TimeSpan.MaxValue
138+
};
139+
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
140+
binding.TransferMode = TransferMode.Streamed;
141+
142+
factory = new ChannelFactory<IWcfServiceGenerated>(binding, new EndpointAddress(Endpoints.Tcp_Streamed_NoSecurity_Address));
143+
serviceProxy = factory.CreateChannel();
144+
145+
// *** EXECUTE *** \\
146+
string result = serviceProxy.Echo(testString);
147+
Assert.Equal(testString, result);
148+
149+
// *** CLEANUP *** \\
150+
((ICommunicationObject)serviceProxy).Close();
151+
factory.Close();
152+
}
153+
finally
154+
{
155+
// *** ENSURE CLEANUP *** \\
156+
ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory);
157+
}
158+
}
121159
}

src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/SingletonConnectionReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ private ValueTask WriteChunkSizeAsync(int size)
623623
if (size > 0)
624624
{
625625
int bytesEncoded = IntEncoder.Encode(size, _encodedSize);
626-
return Connection.WriteAsync(_encodedSize.Slice(0, bytesEncoded), false, TimeSpan.FromMilliseconds(WriteTimeout));
626+
return Connection.WriteAsync(_encodedSize.Slice(0, bytesEncoded), false, TimeoutHelper.FromMilliseconds(WriteTimeout));
627627
}
628628
else
629629
{

0 commit comments

Comments
 (0)