File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 55using System ;
66using System . Net . Security ;
77using System . ServiceModel ;
8+ using System . ServiceModel . Channels ;
89using System . ServiceModel . Description ;
910using System . Threading . Tasks ;
1011
@@ -66,11 +67,22 @@ protected override void OnClosed()
6667 operationContextTaskCompletionSource = null ;
6768 }
6869
69- public static NetNamedPipeBinding CreateBinding ( )
70+ public static CustomBinding CreateBinding ( )
7071 {
7172 var binding = new NetNamedPipeBinding ( NetNamedPipeSecurityMode . None ) ;
7273 binding . MaxReceivedMessageSize = SixteenMegaBytesInBytes ;
73- return binding ;
74+ binding . ReceiveTimeout = TimeSpan . MaxValue ;
75+ binding . SendTimeout = TimeSpan . MaxValue ;
76+ binding . OpenTimeout = TimeSpan . MaxValue ;
77+ binding . CloseTimeout = TimeSpan . MaxValue ;
78+
79+ // Ensure binding connection stays open indefinitely until closed
80+ var customBinding = new CustomBinding ( binding ) ;
81+ var connectionSettings = customBinding . Elements . Find < NamedPipeTransportBindingElement > ( ) . ConnectionPoolSettings ;
82+ connectionSettings . IdleTimeout = TimeSpan . MaxValue ;
83+ connectionSettings . MaxOutboundConnectionsPerEndpoint = 0 ;
84+
85+ return customBinding ;
7486 }
7587 }
7688}
You can’t perform that action at this time.
0 commit comments