4
votes

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.

3

3 Answers

3
votes

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

1
votes

This was driving us nuts too. To solve it make the http (my-amf) first in the default-channels tag and then https (my-secure-amf)

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

If the destinations that use http and https are different destination you can define the channels with order to use for that destination.For example mySecureDestination and myDestination are two different destinations. For mySecureDestination :

<destination id="mySecureDestination" channels="httpsChannel"></destination>

and for non secure http channel

<destination id="myDestination" channels="httpChannel"></destination>