一个 Flex 客户端使用 BlazeDS 连接到两个 Web 应用程序 - 检测到重复的基于 HTTP 的 FlexSession

问题描述:

我有一个 flex 应用程序,它通过 BlazeDS 与在单个 Tomcat 实例中运行的两个 web 应用程序进行通信.

I have a flex application that communicates via BlazeDS with two webapps running inside a single instance of Tomcat.

Flex 客户端由浏览器从第一个 web 应用程序加载,一切正常.但是,在对第二个 web 应用程序的初始调用时,客户端收到以下错误:

The flex client is loaded by the browser from the first webapp and all is well. However on the initial call to the second webapp the client receives the following error:

检测到重复的基于 HTTP 的 FlexSession,通常是由于远程主机禁用了会话 cookie.必须启用会话 cookie 才能正确管理客户端连接.

对同一服务方法的后续调用成功.

Subsequent calls to the same service method succeed.

我已经看到一些关于在两个 flex 应用程序从同一浏览器页面调用单个 web 应用程序的上下文中提到相同错误的帖子,但似乎没有任何帮助我的情况 - 所以我将非常感激任何人都可以帮忙....

I've seen a few posts around referring to the same error in the context of two flex apps calling a single webapp from the same browser page, but nothing which seems to help my situation - so I'd be very grateful if anyone could help out....

干杯,马克

三种可能的解决方案:

  1. 我曾经发现,如果我在设置消息通道之前点击了远程对象,那么 CientID 就会被搞砸.尝试在应用程序加载后和进行任何远程对象调用之前建立初始消息传递通道.

  1. I found once that if I hit a remote object before setting up a messaging channel then the CientID would get screwed up. Try to establish an initial messaging channel once the application loads, and before any remote object calls are made.

Flash Builder 的网络监控工具可能会导致 BlazeDS 出现一些问题.我在应用程序负载上设置了一个配置选项,用于检查我是否在开发环境中(在从 #1 设置我的频道之前调用它).如果我在开发中,我会手动分配一个 UID.出于某种原因,这在开发环境之外不太好用......自从我设置好它已经有一段时间了,所以我不记得为什么更详细的点了:

Flash Builder's network monitoring tool can cause some problems with BlazeDS. I set up a configuration option on application load that checks to see if I'm in the dev environment (it is called just before setting up my channel from #1). If I'm in dev, I assign a UID manually. For some reason this doesn't take well outside the dev environment... been awhile since I set it all up so I can't remember the finer points as to why:

if (!(AppSettingsModel.getInstance().dev))
     FlexClient.getInstance().id = UIDUtil.createUID();

  • 默认情况下,BlazeDS 只允许为每个客户端/浏览器设置一个 HTTP 会话.在我的流媒体频道定义中,我添加了以下内容以允许每个浏览器有额外的会话:

  • BlazeDS by default only allows for a single HTTP session to be setup per client/browser. In my streaming channel definitions I added the following to allow for additional sessions per browser:

    <channel-definition id="my-secure-amf-stream" class="mx.messaging.channels.SecureStreamingAMFChannel"> 
        <endpoint url="https://{server.name}:{server.port}/FlexClient/messagebroker/securestreamingamf"  
            class="flex.messaging.endpoints.SecureStreamingAMFEndpoint"/>
        <properties>
            <add-no-cache-headers>false</add-no-cache-headers>
            <idle-timeout-minutes>0</idle-timeout-minutes> 
            <max-streaming-clients>10</max-streaming-clients> 
            <server-to-client-heartbeat-millis>5000</server-to-client-heartbeat-millis> 
            <user-agent-settings>
                <user-agent match-on="MSIE" kickstart-bytes="2048" max-streaming-connections-per-session="3" /> 
                <user-agent match-on="Firefox" kickstart-bytes="2048" max-streaming-connections-per-session="3" /> 
            </user-agent-settings>
        </properties>