views:

3389

answers:

2

I've been trying to find the right configuration for supporting both http/s requests in a Flex app. I've read all the docs and they allude to doing something like the following:

<default-channels>
  <channel ref="my-secure-amf">
    <serialization>
      <log-property-errors>true</log-property-errors>
    </serialization>
  </channel>
  <channel ref="my-amf">
    <serialization>
      <log-property-errors>true</log-property-errors>
    </serialization>
  </channel>

This works great when hitting the app via https but get intermittent communication failures when hitting the same app via http. Here's an abbreviated services-config.xml:

<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
      <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"
                class="flex.messaging.endpoints.AMFEndpoint"/>
      <properties>
        <!-- HTTPS requests don't work on IE when pragma "no-cache" headers are set so you need to set the add-no-cache-headers property to false -->
        <add-no-cache-headers>false</add-no-cache-headers>
        <!-- Use to limit the client channel's connect attempt to the specified time interval. -->
        <connect-timeout-seconds>10</connect-timeout-seconds>
      </properties>
    </channel-definition>

    <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
      <!--<endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>-->
      <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure"
                class="flex.messaging.endpoints.AMFEndpoint"/>
      <properties>
        <add-no-cache-headers>false</add-no-cache-headers>
        <connect-timeout-seconds>10</connect-timeout-seconds>
      </properties>
    </channel-definition>

I'm running with Tomcat 5.5.17 and Java 5.

  1. The BlazeDS docs say this is the best practice. Is there a better way?
  2. With this config, there seems to be 2-3 retries associated with each channel defined in the default-channels element so it always takes ~20s before the my-amf channel connects via a http request. Is there a way to override the 2-3 retries to say, 1 retry for each channel?

Thanks in advance for answers.

+1  A: 

I have http and https working, although I've only tested it on Firefox and IE7. So far, I'm only using BlazeDS for remoting. Here is my set up:

    <channel-definition id="my-amf"
        class="mx.messaging.channels.AMFChannel">
        <endpoint
            url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"
            class="flex.messaging.endpoints.AMFEndpoint" />
        <properties>
            <polling-enabled>false</polling-enabled>
        </properties>
    </channel-definition>

    <channel-definition id="my-secure-amf"
        class="mx.messaging.channels.SecureAMFChannel">
        <endpoint
            url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure"
            class="flex.messaging.endpoints.SecureAMFEndpoint" />
        <properties>
            <add-no-cache-headers>false</add-no-cache-headers>
        </properties>
    </channel-definition>

You don't specify the app server you're using; it may be an issue. I had some issues when switching from HTTPS to HTTP (secure logins) under Tomcat. One thing I did to troubleshoot was install Jetty and try it there. I'd never used it before, but it was very quick to set up and deploy to, even through Eclipse. I then knew I had a Tomcat specific-problem, which made finding a solution easier (by which I mean possible).

Philip
A: 

Hi

I'm also trying to use HTTP and HTTPS channels at the same time and so my remoting config file looks like:

<default-channels>
    <channel ref="my-amf"/>        
    <channel ref="my-secure-amf" >
</default-channels>

So.. on a server that uses only https we recognized following issue. First the client (flash) tries to connect through the my-amf channel. But because the server allows only https there's a timeout after ~20-25seconds and the reconnect of the client uses the correct my-secure-amf. Ist there a way that flash recognises on https sites to connect the my-secure-amf channel first?

I could reproduce this problem on oc4j (oracle application server) and weblogic.

regards Cyrill

Cyrill Zadra