0 Replies Latest reply on Oct 13, 2009 1:38 AM by roberto_sartori

    Remoteobject call - duplicate HTTP-based FlexSessions

    roberto_sartori

      Hi everyone!

       

      I've already posted my question in the Coldfusion forum,

      but maybe this is the right place... sorry!

       

       

      I have a problem integrating Flex 3 - CF8.
      Server platform: Debian/CF8/Apache2/MySql

       

      On this server, I have 2 separate virtual host/website, say "dns_service_one" and "dns_service_two".
      In each of these, I have a CF application with a test CFC (see code below).
      Session managament are enabled in applications.

       

      In a test Flex application, I call each of two service exposed by the server.
      The problem is that the second call always fail, returning the error below.

       

      Note that separate call will success. The remote service is up and working.
      If I invert call order I obtain the same error.

       

      I I move one service into another server with same configuration, the application works well.
      It seems that I can't call 2 separate service into 2 separate CF application on the same server from a single Flex app ?

       

      Code is below.
      Sorry for the length of my question.
      Thanks for help.

       

      Roberto

       

      ---------------------------------------------------------
      Result in textarea when call service 1 and then service 2
      ---------------------------------------------------------
      "Hello from service 1"

       

      (mx.rpc.events::FaultEvent)#0
        bubbles = false
        cancelable = true
        currentTarget = (null)
        eventPhase = 2
        fault = (mx.rpc::Fault)#1
          content = (Object)#2
          errorID = 0
          faultCode = "Client.Error.MessageSend"
          faultDetail = "Channel.Ping.Failed error null url: 'http://dns_service_two/flex2gateway/servicetwo/'"
          faultString = "Send failed"
          message = "faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Ping.Failed error null url: 'http://dns_service_two/flex2gateway/servicetwo/''"
          .....
           .....
           faultCode = "Server.Processing.DuplicateSessionDetected"
          faultDetail = (null)
          faultString = "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."
          ......
              
          
      ---------------------------------------------------------
      Result in textarea when call service 2 and then service 1
      ---------------------------------------------------------
      "Hello from service 2"

       

      (mx.rpc.events::FaultEvent)#0
        bubbles = false
        cancelable = true
        currentTarget = (null)
        eventPhase = 2
        fault = (mx.rpc::Fault)#1
          content = (Object)#2
          errorID = 0
          faultCode = "Client.Error.MessageSend"
          faultDetail = "Channel.Ping.Failed error null url: 'http://dns_service_one/flex2gateway/serviceone/'"
          faultString = "Send failed"
          message = "faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Ping.Failed error null url: 'http://dns_service_one/flex2gateway/serviceone/''"
          name = "Error"
           .....
           .....
           faultCode = "Server.Processing.DuplicateSessionDetected"
          faultDetail = (null)
          faultString = "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."
          ......

       

      ---------------------------------
      flex_service.cfc (on service one)
      ---------------------------------

       

      <cfcomponent>

       

          <cffunction name="hello" output="false" access="remote" returntype="any">
              <cfreturn 'Hello from service 1'>
          </cffunction>

       

      </cfcomponent>

       


      ---------------------------------
      flex_service.cfc (on service two)
      ---------------------------------

       


      <cfcomponent>

       


          <cffunction name="hello" output="false" access="remote" returntype="any">
              <cfreturn 'Hello from service 2'>
          </cffunction>

       


      </cfcomponent>

       


      --------------
      Test.mxml
      --------------

       


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

       


      <mx:Script>
          <![CDATA[
              import mx.rpc.AsyncResponder;
              import mx.rpc.AsyncToken;
              import mx.messaging.channels.AMFChannel;
              import mx.messaging.ChannelSet;
              import mx.rpc.remoting.RemoteObject;
              import mx.rpc.events.ResultEvent;
              import mx.utils.ObjectUtil;
              import mx.rpc.events.FaultEvent;
              import mx.rpc.IResponder;
            
              private function get ChannelsOne () : ChannelSet
             {
                    var channels:ChannelSet = new ChannelSet();
                    var channel:AMFChannel = new AMFChannel();
                  channel.uri = 'http://dns_service_one/flex2gateway/serviceone/';
                  channels.addChannel(channel);
                 return channels;
             }
           
             private function get ChannelsTwo () : ChannelSet
             {
                    var channels:ChannelSet = new ChannelSet();
                    var channel:AMFChannel = new AMFChannel();
                  channel.uri = 'http://dns_service_two/flex2gateway/servicetwo/';
                  channels.addChannel(channel);
                 return channels;
             }
            
              public function get RemoteObjOne () : RemoteObject
             {
                 var remoteObj:RemoteObject = new RemoteObject();
                 remoteObj.destination = 'DestinationOne';
                  remoteObj.source = 'flex_service';
                  remoteObj.channelSet = ChannelsOne;
                  return remoteObj;
                }
              
                public function get RemoteObjTwo () : RemoteObject
             {
                 var remoteObj:RemoteObject = new RemoteObject();
                 remoteObj.destination = 'DestinationTwo';
                  remoteObj.source = 'flex_service';
                  remoteObj.channelSet = ChannelsTwo;
                  return remoteObj;
                }
            
              private function service1_OnClick (evt:MouseEvent) : void
              {
                  var call:AsyncToken = RemoteObjOne.getOperation('hello').send();
                  var resp:IResponder = new AsyncResponder(RemoteObjOne_OnResult, RemoteObjOne_OnFault);
                  call.addResponder(resp);  
              }
            
              private function service2_OnClick (evt:MouseEvent) : void
              {
                  var call:AsyncToken = RemoteObjTwo.getOperation('hello').send();
                  var resp:IResponder = new AsyncResponder(RemoteObjTwo_OnResult, RemoteObjTwo_OnFault);
                  call.addResponder(resp);  
              }
            
              private function RemoteObjOne_OnResult (evt:ResultEvent, token:Object) : void
              {
                  txtResult.text += ObjectUtil.toString(evt.result) + '\n';
              }
            
              private function RemoteObjOne_OnFault (evt:FaultEvent, token:Object) : void
              {
                  txtResult.text += ObjectUtil.toString(evt) + '\n';
              }
            
              private function RemoteObjTwo_OnResult (evt:ResultEvent, token:Object) : void
              {
                  txtResult.text += ObjectUtil.toString(evt.result) + '\n';
              }
            
              private function RemoteObjTwo_OnFault (evt:FaultEvent, token:Object) : void
              {
                  txtResult.text += ObjectUtil.toString(evt) + '\n';
              }
            
          ]]>
      </mx:Script>

       


          <mx:Button x="10" y="10" label="Invoke service 1" click="service1_OnClick(event)"/>
          <mx:Button x="140" y="10" label="Invoke service 2" click="service2_OnClick(event)"/>
          <mx:TextArea id="txtResult" left="10" top="40" bottom="10" right="10"/>
        
      </mx:Application>

       


      -------------------------------------------------------
      services-config.xml (default with 2 additional channel)
      -------------------------------------------------------

       


      <?xml version="1.0" encoding="UTF-8"?>
      <services-config>

       


          .....

       


          <channels>
            
              <channel-definition id="channel1" class="mx.messaging.channels.AMFChannel">
                  <endpoint uri="http://{server.name}:{server.port}{context.root}/flex2gateway/serviceone" class="flex.messaging.endpoints.AMFEndpoint"/>
                  <properties>
                      <polling-enabled>false</polling-enabled>
                      <serialization>
                         <instantiate-types>false</instantiate-types>
                      </serialization>
                 </properties>
              </channel-definition>

       


              <channel-definition id="channel2" class="mx.messaging.channels.AMFChannel">
                  <endpoint uri="http://{server.name}:{server.port}{context.root}/flex2gateway/servicetwo" class="flex.messaging.endpoints.AMFEndpoint"/>
                  <properties>
                      <polling-enabled>false</polling-enabled>
                      <serialization>
                         <instantiate-types>false</instantiate-types>
                      </serialization>
                 </properties>
              </channel-definition>

       


              .....
            
          </channels>
        
          .....
        
      </services-config>

       

       

       

      -----------------------------------------------------------
      remoting-config.xml (default with 2 additional destination)
      -----------------------------------------------------------

       


      <?xml version="1.0" encoding="UTF-8"?>
      <service id="remoting-service"
          class="flex.messaging.services.RemotingService"
          messageTypes="flex.messaging.messages.RemotingMessage">
          
           ....

       


          <destination id="DestinationOne">
            <channels>
               <channel ref="channel1"/>
            </channels>
            <properties>
               <source>*</source>
               <access>
                   <use-mappings>false</use-mappings>
                   <method-access-level>remote</method-access-level>
               </access>
               <property-case>
                   <force-cfc-lowercase>false</force-cfc-lowercase>
                   <force-query-lowercase>false</force-query-lowercase>
                   <force-struct-lowercase>false</force-struct-lowercase>
               </property-case>
            </properties>
         </destination>
        
          <destination id="DestinationTwo">
            <channels>
               <channel ref="channel2"/>
            </channels>
            <properties>
               <source>*</source>
               <access>
                   <use-mappings>false</use-mappings>
                   <method-access-level>remote</method-access-level>
               </access>
               <property-case>
                   <force-cfc-lowercase>false</force-cfc-lowercase>
                   <force-query-lowercase>false</force-query-lowercase>
                   <force-struct-lowercase>false</force-struct-lowercase>
               </property-case>
            </properties>
         </destination>
            
          ....
        
      </service>