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

发布于 2024-10-26 11:32:31 字数 376 浏览 1 评论 0原文

我有一个 Flex 应用程序,它通过 BlazeDS 与单个 Tomcat 实例中运行的两个 Web 应用程序进行通信。

Flex 客户端由浏览器从第一个 Web 应用程序加载,一切正常。但是,在首次调用第二个 Web 应用程序时,客户端收到以下错误:

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

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

我看过一些帖子,在两个 Flex 应用程序从同一浏览器页面调用单个 Web 应用程序的上下文中提到相同的错误,但似乎没有任何内容对我的情况有帮助 - 所以如果有人可以提供帮助,我将非常感激出去......

干杯,马克

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

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:

Detected duplicate HTTP-based FlexSessions, generally due to the remote host disabling session cookies. Session cookies must be enabled to manage the client connection correctly.

Subsequent calls to the same service method succeed.

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....

Cheers, Mark

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小嗲 2024-11-02 11:32:31

为您提供三个潜在的解决方案:

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

  2. Flash Builder 的网络监控工具可能会导致 BlazeDS 出现一些问题。我在应用程序加载上设置了一个配置选项,用于检查我是否处于开发环境中(在设置 #1 的通道之前调用它)。如果我在开发部门,我会手动分配一个 UID。由于某种原因,这在开发环境之外并不能很好地发挥作用...自从我将其全部设置好以来已经有一段时间了,所以我不记得为什么要这样做:

    if (!(AppSettingsModel.getInstance().dev))
         FlexClient.getInstance().id = UIDUtil.createUID();
    
  3. BlazeDS 默认情况下只允许单个 HTTP 会话根据客户端/浏览器进行设置。在我的流媒体通道定义中,我添加了以下内容以允许每个浏览器进行额外的会话:

    ; 
        <端点 url="https://{server.name}:{server.port}/FlexClient/messagebroker/securestreamingamf"  
            类=“flex.messaging.endpoints.SecureStreamingAMFEndpoint”/>
        <属性>
            false;
            <空闲超时分钟数>00 
            <最大流客户端>1010 
            <服务器到客户端心跳毫秒>50005000 
            <用户代理设置>
                 
                 
            
        
    

Three potential solutions for you:

  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.

  2. 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();
    
  3. 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>
    
零度℉ 2024-11-02 11:32:31

问题:当 flex.warLivecycle.lca 文件托管在 WebSphere Server 上的单独 JVM 中时,出现重复会话错误。

解决方案:
在事件的命令文件内,在调用远程服务(Java 方法或 LC Process)之前,在执行方法中将 FlexClientId 设置为 null。
我猜这种方法也可以在其他场景中使用,以防止重复会话错误。

EventCommand.as file
—————————–

import mx.messaging.FlexClient;
//other imports as per your code

public function execute(event:CairngormEvent):void
{
    var evt:EventName = event as EventName ;

    var delegate:Delegate = new DelegateImpl(this as IResponder);

    //***set client ID to null
    FlexClient.getInstance().id = null;

    delegate.functionName(evt.data);
}

Problem: Duplicate session errors when flex.war and Livecycle.lca files are hosted in separate JVMs on WebSphere Server.

Solution:
Inside the command file for the event, set FlexClientId to null in execute method before calling remote service (Java method or LC Process).
Guess this approach can be used in other scenarios as well to prevent Duplicate session errors.

EventCommand.as file
—————————–

import mx.messaging.FlexClient;
//other imports as per your code

public function execute(event:CairngormEvent):void
{
    var evt:EventName = event as EventName ;

    var delegate:Delegate = new DelegateImpl(this as IResponder);

    //***set client ID to null
    FlexClient.getInstance().id = null;

    delegate.functionName(evt.data);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文