代码之家  ›  专栏  ›  技术社区  ›  digitalsanctum

如何在flex/blazeds中同时支持http和https通道?

  •  4
  • digitalsanctum  · 技术社区  · 16 年前

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

    提前谢谢你的回答。

    3 回复  |  直到 12 年前
        1
  •  3
  •   Philip    16 年前

    我有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
  •  1
  •   Java Bug    14 年前

    这也让我们疯了。要解决这个问题,首先在默认的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
  •  0
  •   Uriah Carpenter    12 年前

    如果使用HTTP和HTTPS的目的地是不同的目的地,则可以定义要为该目的地使用的通道。例如MySeCUREST和MyTestObjor是两个不同的目的地。对于我的安全目标:

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

    对于非安全的http通道

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