AppFabric缓存将大对象添加到远程服务器

时间:2013-11-21 15:10:29

标签: c# wcf caching appfabric

我正在为Windows Server 1.1使用AppFabric缓存。我正在尝试将80MB的对象添加到位于网络上另一台服务器上的缓存中。我收到以下错误:

  

ErrorCode:SubStatus:暂时失败。   请稍后重试。 (一个或多个指定的缓存服务器   不可用,这可能是由繁忙的网络或服务器引起的。对于   内部部署缓存集群,还验证以下条件。   确保已为此客户端授予安全权限   帐户,并检查是否允许AppFabric缓存服务   通过所有缓存主机上的防火墙。还有MaxBufferSize   server必须大于或等于序列化对象大小   从客户发送。):内心   System.ServiceModel.CommunicationException:套接字已中止   因为从套接字的异步接收没有完成   在分配的超时00:01:00内。分配给此的时间   操作可能是较长超时的一部分。 --->   System.Net.Sockets.SocketException:建立的连接是   被主机上的软件中止   System.ServiceModel.Channels.SocketConnection.Write(Byte []缓冲区,   Int32偏移量,Int32大小,布尔立即数,TimeSpan超时)---   内部异常堆栈跟踪结束--- at   System.ServiceModel.Channels.SocketConnection.Write(Byte []缓冲区,   Int32偏移量,Int32大小,布尔值立即数,TimeSpan超时)at   System.ServiceModel.Channels.SocketConnection.Write(Byte []缓冲区,   Int32偏移量,Int32大小,布尔立即数,TimeSpan超时,   BufferManager bufferManager)at   System.ServiceModel.Channels.BufferedConnection.WriteNow(字节[]   缓冲区,Int32偏移量,Int32大小,TimeSpan超时,BufferManager   bufferManager)at   System.ServiceModel.Channels.BufferedConnection.Write(Byte [] buffer,   Int32偏移量,Int32大小,布尔立即数,TimeSpan超时,   BufferManager bufferManager)at   System.ServiceModel.Channels.FramingDuplexSessionChannel.OnSend(消息   消息,TimeSpan超时)at   System.ServiceModel.Channels.OutputChannel.Send(消息消息,   TimeSpan超时)at   Microsoft.ApplicationServer.Caching.WcfClientChannel.SendOnChannel(的EndpointId   端点,TimeSpan& timeout,WaitCallback回调,对象状态,   布尔异步,IDuplexSessionChannel通道,消息消息)

我可以将较小的对象添加到远程服务器中,这显然与大小有关。我还为AppFabric安装了累积更新包3。我已禁用所有安全性。有什么想法吗?

服务器配置文件:

<configuration>
    <configSections>
        <section name="dataCache" type="Microsoft.ApplicationServer.Caching.DataCacheSection, Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </configSections>
    <dataCache size="Small">
        <caches partitionCount="32">
            <cache consistency="StrongConsistency" name="default" minSecondaries="0">
                <policy>
                    <eviction type="Lru" />
                    <expiration defaultTTL="1440" isExpirable="true" />
                </policy>
            </cache>
        </caches>
        <hosts>
            <host replicationPort="22236" arbitrationPort="22235" clusterPort="22234"
                hostId="1216617116" size="6126" leadHost="true" account="test$"
                cacheHostName="AppFabricCachingService" name="test.com"
                cachePort="22233" />
        </hosts>
        <advancedProperties>
            <securityProperties mode="None" protectionLevel="None">
                <authorization>
                    <allow users="IIS AppPool\test" />
                </authorization>
            </securityProperties>
            <transportProperties maxBufferPoolSize="26843545600" maxBufferSize="838860800" receiveTimeout="40000" />
        </advancedProperties>
        <deploymentSettings>
            <deploymentMode value="RoutingClient" />
        </deploymentSettings>
    </dataCache>
</configuration>

客户端的Web.config中试图推送到AppFabric的部分:

<dataCacheClient requestTimeout="60000" channelOpenTimeout="12000" maxConnectionsToServer="1">
    <localCache isEnabled="false" sync="TimeoutBased" ttlValue="300" objectCount="10000"/>
    <clientNotification pollInterval="300" maxQueueLength="10000"/>        
    <securityProperties mode="None" protectionLevel="None" />
    <transportProperties connectionBufferSize="131072" maxBufferPoolSize="568435456" maxBufferSize="183886080" maxOutputDelay="2" channelInitializationTimeout="60000" receiveTimeout="60000" />  </dataCacheClient>

连接在代码中建立如下:

DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1];
                servers[0] = new DataCacheServerEndpoint("remoteServerName", 22233);

                DataCacheFactoryConfiguration factoryConfig = new DataCacheFactoryConfiguration();
                factoryConfig.Servers = servers;

                //Pass configuration settings to cacheFactory constructor
                _factory = new DataCacheFactory(factoryConfig);

                _cache = _factory.GetCache("default");

最后是将项添加到缓存的代码:

_cache.CreateRegion(region);                             
_cache.Put(key, value, new TimeSpan(0, timeToLive, 0), tag, region); 

1 个答案:

答案 0 :(得分:2)

此问题的解决方案是在客户端web.config中增加requestTimeout并删除receiveTimeout设置。

web.config现在看起来像:

<dataCacheClient requestTimeout="600000" channelOpenTimeout="12000" maxConnectionsToServer="1">
    <localCache isEnabled="false" sync="TimeoutBased" ttlValue="300" objectCount="10000"/>
    <clientNotification pollInterval="300" maxQueueLength="10000"/>        
    <securityProperties mode="None" protectionLevel="None" />
    <transportProperties connectionBufferSize="131072" maxBufferPoolSize="568435456" maxBufferSize="183886080" maxOutputDelay="2" channelInitializationTimeout="60000" />  </dataCacheClient>