AppFabric 缓存 - 现有连接被远程主机强制关闭
-
26-09-2019 - |
题
我正在尝试在本地开发环境中启动并运行 AppFabric 缓存。我有 Windows Server AppFabric Beta 2 刷新 安装完毕,缓存集群和主机已配置并开始在 Windows 7 64 位上运行。我在集成模式下的 v4.0 应用程序池下的本地 IIS 网站中运行我的 MVC2 网站。
HostName : CachePort Service Name Service Status Version Info
-------------------- ------------ -------------- ------------
SN-3TQHQL1:22233 AppFabricCachingService UP 1 [1,1][1,1]
我的 web.config 配置如下:
<configSections>
<section name="dataCacheClient" type="Microsoft.ApplicationServer.Caching.DataCacheClientSection, Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" allowLocation="true" allowDefinition="Everywhere"/>
</configSections>
<dataCacheClient>
<hosts>
<host name="SN-3TQHQL1" cachePort="22233" />
</hosts>
</dataCacheClient>
当我尝试初始化 DataCacheFactory 时出现错误:
protected CacheService()
{
_cacheFactory = new DataCacheFactory(); <-- Error here
_defaultCache = _cacheFactory.GetDefaultCache();
}
我收到 ASP.NET 黄色错误屏幕,其中包含以下内容:
现有连接被远程主机强制关闭
描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。
异常详细信息:System.Net.Sockets.SocketException:现有连接被远程主机强制关闭
来源错误:
Line 21: protected CacheService()
Line 22: {
Line 23: _cacheFactory = new DataCacheFactory();
Line 24: _defaultCache = _cacheFactory.GetDefaultCache();
Line 25: }
解决方案
我有一个类似的问题还有,我的问题是我没有给适当的权限缓存客户端。为了快速验证这是我将给予缓存中的每一个人帐户访问的问题。如果这能解决问题,那么考虑限制访问到相应的帐户,而不是所有人。这可以实现通过“高速缓存管理器的Windows PowerShell”,这是在将Windows Server AppFabric的开始菜单文件夹中找到执行以下命令:
Grant-CacheAllowedClientAccount everyone
其他提示
我也遇到了这个问题,我在这个帖子中找到了答案:
答案:
由于客户端和服务器之间的安全属性不匹配,因此您看到了此错误。
在您的客户端代码中,您禁用了安全性(模式= none and potectionLevel = none),而缓存服务器使用模式=传输和PotectionLevel = EncryptAndSign(beta2fresh bits中的默认值)。
执行以下任一操作:
1)在客户端代码中使用默认安全性,即配置.SecurityProperties =new DataCacheSecurity();
2)禁用服务器的安全性,以与您现有的客户端代码匹配。使用powershell cmdlet set -cacheclustersecurity -securityMode无-ProtectionLevel无
做,如果你使用DataCacheFactoryConfiguration对象你会得到同样的问题? e.g。
protected CacheService()
{
DataCacheFactoryConfiguration config;
List<DataCacheServerEndpoint> endpoints;
DataCacheFactory factory;
DataCache cache;
endpoints = new List<DataCacheServerEndpoint>();
endpoints.Add(new DataCacheServerEndpoint("SN-3TQHQL1",22233));
config = new DataCacheFactoryConfiguration();
config.Servers = endpoints;
factory = new DataCacheFactory(config);
cache = factory.GetDefaultCache();
...
}
你有没有打开的端口上的防火墙?
或许检查条目在事件日志 - 他们可能会提供线索,什么是(或不是)发生