尝试将会话状态存储在 Windows Azure Web 服务的 AppFabricCache 中时引发的 Socket

本文关键字:AppFabricCache Socket 服务 Web 会话状态 存储 Azure Windows | 更新日期: 2023-09-27 18:24:04

我正在尝试一个简单的示例项目,以了解如何配置Windows Azure云服务以使用共存缓存。

正在使用VS2010并遵循此示例,但是当我到达有关共存缓存的部分结束时,我无法在本地运行我的项目。它在以下情况下工作正常

我遇到以下异常:(我希望它是可读的..(

"/"应用程序中出错。

请求

的名称有效,但未找到所请求类型的数据

说明:执行当前 Web 请求期间发生未经处理的异常。请查看堆栈跟踪,了解有关错误及其在代码中起源位置的详细信息。

异常详细信息:System.Net.Sockets.SocketException:请求的名称有效,但未找到请求类型的数据

源错误:

执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常来源和位置的信息。

堆栈跟踪:

[套接字异常 (0x2afc(:请求的名称有效,但未找到所请求类型的数据] Microsoft.ApplicationServer.Caching.AsyncResultNoResult.EndInvoke(( +202 Microsoft.ApplicationServer.Caching.AsyncResult'1.EndInvoke(( +40 Microsoft.ApplicationServer.Caching.SocketConnectionFactory.EndConnect(IAsyncResult asyncResult( +75 Microsoft.ApplicationServer.Caching.TcpClientChannelFactory.TcpConnectionCallback(IAsyncResult result( +182

[数据缓存异常: 错误代码:子状态:存在临时故障。请稍后重试。(一个或多个指定的缓存服务器不可用,这可能是由繁忙的网络或服务器引起的。对于本地缓存群集,还要验证以下条件。确保已为此客户端帐户授予安全权限,并检查是否允许 AppFabric 缓存服务通过所有缓存主机上的防火墙。此外,服务器上的 MaxBufferSize 必须大于或等于从客户端发送的序列化对象大小。附加信息:客户端正在尝试与服务器通信:net.tcp://SessionStateDemo:24233。 Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ErrStatus errStatus, Guid trackingId, Exception responseException, Byte[][] payload, EndpointID destination( +767 Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody, EndpointID destination( +149 Microsoft.ApplicationServer.Caching.DataCacheFactory.EstablishConnection(IEnumerable 1 servers, RequestBody request, Func 3 sendMessageDelegate, DataCacheReadyRetryPolicy retryPolicy( +1313 Microsoft.ApplicationServer.Caching.<>c__DisplayClass5.b__2(RequestBody req( +198 Microsoft.ApplicationServer.Caching.SocketClientProtocol.SendReceive(IVelocityRequestPacket request, Func 2 delegate, EndpointID& destination) +121 Microsoft.ApplicationServer.Caching.SocketClientProtocol.Initialize(IEnumerable 1 台服务器( +1225 Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName, CreateNewCacheDelegate cacheCreationDelegate, DataCacheInitializationViaCopyDelegate initializeDelegate( +1104 Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName( +131 Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFromFactory(DataCacheFactory factory, String cacheName( +63 Microsoft.Web.DistributedCache.CacheHelpers.RunCacheCreationHooks(CacheConnectingEventArgs fetchingEventArgs, IDataCacheFactory dataCacheFactory, Object sender, EventHandler 1 fetchingHandler, EventHandler 1 fetchedHandler( +306 Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateInternalProvider(IHttpRuntime httpRuntime, SessionInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler 1 cacheFetching, EventHandler 1 cacheFetched( +399 Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.GetInternalProvider(( +315 Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateNewStoreData(HttpContext context, Int32 timeout( +59 System.Web.SessionState.SessionStateModule.InitStateStoreItem(Boolean addToContext( +160 System.Web.SessionState.SessionStateModule.CompleteAcquireState(( +340 System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData( +1269 System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute(( +12698078 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completeSyncally( +288

谁能告诉我这里发生了什么?我该如何解决这个问题?

该教程中是否缺少我需要执行的操作?

编辑:我正在使用VS2010 Professional,Windows Azure SDK 2.1。Widnows Azure Cache 包是 v2.1.0。

相关 web.config 部分:

<system.web>
...
<!-- Windows Azure Caching session state provider -->
    <sessionState mode="Custom" customProvider="AFCacheSessionStateProvider">
      <providers>
        <add name="AFCacheSessionStateProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" dataCacheClientName="default" applicationName="AFCacheSessionState"/>
      </providers>
    </sessionState>
...
<sytem.web>
    <dataCacheClients>
    <dataCacheClient name="default">
      <!--To use the in-role flavor of Windows Azure Caching, set identifier to be the cache cluster role name -->
      <autoDiscover isEnabled="true" identifier="SessionStateDemo" />
    </dataCacheClient>
  </dataCacheClients>

尝试将会话状态存储在 Windows Azure Web 服务的 AppFabricCache 中时引发的 Socket

基于此线程,Windows Azure 云服务似乎必须是一个启动项目才能正常工作。否则,Windows Azure 运行时不会初始化导致套接字异常的原因。