java - 如何在 Flex/BlazeDS 中同时支持 HTTP 和 HTTPS channel ?

标签 java apache-flex flex3 remoting blazeds

我一直在努力寻找在 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 次重试与 default-channels 元素中定义的每个 channel 相关联,因此在 my-amf channel 通过 http 请求连接之前总是需要大约 20 秒。有没有办法覆盖 2-3 次重试,即每个 channel 重试 1 次?

提前感谢您的回答。

最佳答案

虽然我只在 Firefox 和 IE7 上测试过,但我可以使用 http 和 https。到目前为止,我只使用 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 特定问题,这使得找到解决方案变得更加容易(我的意思是可能)。

关于java - 如何在 Flex/BlazeDS 中同时支持 HTTP 和 HTTPS channel ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1009675/

相关文章:

java - 请分享一些关于java中的rehash方法的见解?

java - 使用 Java 反射时出现 NoSuchMethodException

java - 尝试读取文件并将其值添加到 JFrame 时出现问题

apache-flex - 如何在Flex中自定义HSlider?

actionscript-3 - 如何在 ActionScript 3 中创建数组的浅拷贝

apache-flex - Flex 中数组和数组集合的区别

java - 什么时候收集 perm gen?

apache-flex - 带组的 Flex 4 滚动条。滚动条不显示

java - 将对象从flex发送到java servlet

json - 如何在 Flex 3 中使用原生 JSON 或 actionjson 解码 Json