One Flex client connecting to two webapps using Bl

2019-04-15 06:32发布

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

标签: flex blazeds
2条回答
一纸荒年 Trace。
2楼-- · 2019-04-15 07:11

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>
    
查看更多
何必那么认真
3楼-- · 2019-04-15 07:13

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);
}
查看更多
登录 后发表回答