【问题标题】:How to support both HTTP and HTTPS channels in Flex/BlazeDS?如何在 Flex/BlazeDS 中同时支持 HTTP 和 HTTPS 通道?
【发布时间】:2009-06-17 21:42:44
【问题描述】:

我一直在尝试找到正确的配置来支持 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 次?

提前感谢您的回答。

【问题讨论】:

    标签: java apache-flex flex3 remoting blazeds


    【解决方案1】:

    我有 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 特定问题,这使得找到解决方案变得更容易(我的意思是可能的)。

    【讨论】:

      【解决方案2】:

      这也让我们发疯了。为了解决这个问题,首先在 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>
      

      【讨论】:

        【解决方案3】:

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

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

        对于非安全的 http 通道

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-11-30
          • 2023-04-02
          • 2022-07-14
          • 1970-01-01
          • 2010-10-05
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多