WCF服务方法调用时间增长

时间:2013-06-27 08:46:54

标签: c# .net wcf mono

在raspberry pi上安装是单声道最新稳定版,使用.NET 4.5从服务器上的服务轮询数据。

我的服务器端配置:

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="vlcBehaviour">
          <serviceMetadata  httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <services>
      <service name="ser.Serwys">
        <endpoint address="net.tcp://192.168.56.1:9070/WindowService" binding="netTcpBinding" bindingConfiguration="AnonymousTcpBinding"
                  contract="Window.Service.IWindowServiceHost" />
      </service>
    </services>

    <bindings>
      <netTcpBinding>
        <binding name="AnonymousTcpBinding" receiveTimeout="00:00:01"
                 sendTimeout="00:00:01"
                 maxBufferSize="1000"
                 maxConnections="100"
                 maxBufferPoolSize="100"
                 listenBacklog="200"
                 maxReceivedMessageSize="1000">
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>

在客户端:

<system.serviceModel>
    <behaviors>
        <endpointBehaviors>
            <behavior name="maxItems">
                <dataContractSerializer maxItemsInObjectGraph="2147483646" />
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <bindings>
        <netTcpBinding>
            <binding name="AnonymousTcpBinding" openTimeout="00:00:01" receiveTimeout="00:00:01" sendTimeout="00:00:01" maxBufferSize="1000" maxConnections="200" listenBacklog="200" maxReceivedMessageSize="1000">
                <security mode="None" />
            </binding>
        </netTcpBinding>
    </bindings>
    <client>
        <endpoint name="WindowService" address="net.tcp://192.168.56.1:9070/WindowService" binding="netTcpBinding" bindingConfiguration="AnonymousTcpBinding" contract="Window.Service.IWindowServiceHost" />
    </client>
</system.serviceModel>

服务合同:

namespace Window.Service
{
    [ServiceContract(
        Namespace = "http://window",
        Name = "WindowHost")]
    public interface IWindowServiceHost
    {
        [OperationContract]
        void Connect(int windowId);

        [OperationContract]
        void Disconnect();

        [OperationContract]
        DisplayData GetData();
    }
}

服务的实施:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single)]
    public class Serwys:IWindowServiceHost

调用的方法:

    public DisplayData GetData()
    {
        Console.WriteLine("Called get data {0}:{1}:{2}",DateTime.Now.Minute,DateTime.Now.Second,DateTime.Now.Millisecond);
        return new DisplayData
        {
            BoxesInProgress = 1,
        };
    }

从客户端调用GetData需要花费越来越多的时间,不知道为什么。 我已经在Ubuntu上测试了它,Mono是最新版本,我如何记录它:

Stopwatch stp = new Stopwatch();
stp.Start();
var data = remote.GetData();
stp.Stop();
log.WarnFormat("Polling service took: {0} ms", stp.ElapsedMilliseconds);

任何解释?我认为这是Mono bug,因为设置是非常基本的,没有并发方法称为死简单,并且轮询时间正在增加。

我在计时器过去时调用它,为了测试我每隔10ms调用一次,但即使我每秒都调用它,它也在增长,但速度较慢,这只会让我在所有崩溃之前有更多的时间。

0 个答案:

没有答案