更新:
我一直试图打开WCF跟踪,但仍然没有成功......以下是我最新的更新.
我是否需要获得写入以下位置的许可?
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="sdt"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "@\\myservername\folder1\traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
Run Code Online (Sandbox Code Playgroud)
我正在使用.NET Framework 3.5.
为调试目的打开WCF跟踪的逐步说明是什么?
我正在使用两个应用程序,一个具有配置为使用net.tcp绑定的自托管服务.该服务的ServiceBehaviorAttribute配置为:
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple,
InstanceContextMode = InstanceContextMode.Single,
IncludeExceptionDetailInFaults = true,
UseSynchronizationContext = false,
ValidateMustUnderstand = false)]
Run Code Online (Sandbox Code Playgroud)
对于服务和客户端,transferMode设置为Streamed,超时为:
closeTimeout="00:01:00"
openTimeout="00:00:30"
receiveTimeout="00:02:30"
sendTimeout="00:02:30"
Run Code Online (Sandbox Code Playgroud)
MaxConnections设置为500,ServiceThrottlingBehavior使用WCF 4默认值:
我使用的是四核机器,并启用了Net.Tcp端口共享服务.
客户端应用程序具有使用ChannelFactory类创建的服务的单个通道.创建通道后,会生成100个线程.每个线程使用该通道以每秒一条消息的频率向服务器发送消息.
运行ok几秒钟后(客户端向服务器发送消息并正确接收它们)会抛出EndpointNotFoundException,并显示以下消息:
Could not connect to net.tcp://localhost/service. The connection attempt lasted
for a time span of 00:00:02.1777100. TCP error code 10061: No connection could
be made because the target machine actively refused it 127.0.0.1:808.
Run Code Online (Sandbox Code Playgroud)
奇怪的事情是:
我做了很多测试,减少线程数量,增加线程数量,更改关闭,打开,接收和发送超时值到更低和更高的值,为maxConnections设置更高的值但结果总是相同的,在某些时候抛出EndpointNotFoundException.我即将放弃并更改代码,以便每个线程都有自己的通道,希望这可以解决问题,但我想知道为什么会发生这种情况.如果有人知道我做错了什么或者能指出我正确的方向继续调查它会有所帮助.