4

我一直在尝试找到正确的配置来支持 Flex 应用程序中的两个 http/s 请求。我已经阅读了所有的文档,他们提到做如下的事情:

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

这在通过 https 访问应用程序时效果很好,但在通过 http 访问同一应用程序时会出现间歇性通信失败。这是一个缩写的 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>

我正在使用 Tomcat 5.5.17 和 Java 5 运行。

  1. BlazeDS 文档说这是最佳实践。有没有更好的办法?
  2. 使用此配置,默认通道元素中定义的每个通道似乎有 2-3 次重试,因此在 my-amf 通道通过 http 请求连接之前总是需要大约 20 秒。有没有办法覆盖 2-3 次重试,比如每个频道重试 1 次?

提前感谢您的回答。

4

3 回答 3

3

我有 http 和 https 工作,虽然我只在 Firefox 和 IE7 上测试过。到目前为止,我只使用 BlazeDS 进行远程处理。这是我的设置:

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

您没有指定您正在使用的应用服务器;这可能是个问题。在 Tomcat 下从 HTTPS 切换到 HTTP(安全登录)时遇到了一些问题。我为排除故障所做的一件事是安装 Jetty 并在那里尝试。我以前从未使用过它,但它的设置和部署速度非常快,即使通过 Eclipse 也是如此。然后我知道我有一个 Tomcat 特定问题,这使得找到解决方案变得更容易(我的意思是可能的)。

于 2009-06-18T08:55:04.380 回答
1

这也让我们发疯了。为了解决这个问题,首先在 default-channels 标签中创建 http (my-amf),然后是 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>
于 2012-03-15T15:39:44.520 回答
0

如果使用 http 和 https 的目的地是不同的目的地,您可以使用顺序定义用于该目的地的通道。例如 mySecureDestination 和 myDestination 是两个不同的目的地。对于 mySecureDestination :

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

对于非安全的 http 通道

<destination id="myDestination" channels="httpChannel"></destination>
于 2011-07-13T09:13:39.347 回答