【问题标题】:Talking to the spdy server with java client使用 java 客户端与 spdy 服务器对话
【发布时间】:2013-03-18 20:03:43
【问题描述】:

我已经使用 jetty9 启动了一个 spdy 代理服务器。

jetty-spdy-proxy.xml:

<New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
  <Set name="KeyStorePath"><Property name="jetty.home" default="." />/etc/keystore</Set>
  <Set name="KeyStorePassword">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
  <Set name="KeyManagerPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>
  <Set name="TrustStorePath"><Property name="jetty.home" default="." />/etc/keystore</Set>
  <Set name="TrustStorePassword">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
</New>

<New id="tlsHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
  <Arg><Ref refid="httpConfig"/></Arg>
  <Call name="addCustomizer">
    <Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg>
  </Call>
</New>

<Call name="addConnector">
  <Arg>
    <New class="org.eclipse.jetty.server.ServerConnector">
      <Arg name="server"><Ref id="Server" /></Arg>
      <Arg name="factories">
        <Array type="org.eclipse.jetty.server.ConnectionFactory">
          <Item>
            <New class="org.eclipse.jetty.server.HttpConnectionFactory">
              <Arg name="config"><Ref id="httpConfig" /></Arg>
            </New>
          </Item>
        </Array>
      </Arg>
      <Set name="host"><Property name="jetty.host" /></Set>
      <Set name="port"><Property name="jetty.port" default="9090" /></Set>
      <Set name="idleTimeout">30000</Set>
    </New>
  </Arg>
</Call>

http/1.1 本地主机 http/1.1 127.0.0.1 9090

8080 8443

此服务器已正常启动。

2013-03-28 17:49:02.623:INFO:oejsh.ContextHandler:main: started o.e.j.w.WebAppContext@4a734beb{/test,file:/tmp/jetty-0.0.0.0-8443-test.war-_test-any-/webapp/,AVAILABLE}{/test.war}
2013-03-28 17:49:02.911:WARN::main: async-rest webapp is deployed. DO NOT USE IN PRODUCTION!
2013-03-28 17:49:02.990:INFO:oejsh.ContextHandler:main: started o.e.j.w.WebAppContext@28245558{/async-rest,[file:/tmp/jetty-0.0.0.0-8443-async-rest.war-_async-rest-any-/webapp/, jar:file:/tmp/jetty-0.0.0.0-8443-async-rest.war-_async-rest-any-/webapp/WEB-INF/lib/example-async-rest-jar-9.0.0.v20130308.jar!/META-INF/resources/],AVAILABLE}{/async-rest.war}
2013-03-28 17:49:03.061:INFO:oejsh.ContextHandler:main: started o.e.j.s.h.MovedContextHandler@b102b93{/oldContextPath,null,AVAILABLE}
2013-03-28 17:49:03.159:INFO:oejsh.ContextHandler:main: started o.e.j.s.h.ContextHandler@36858c07{/javadoc,file:/home/sankuai/jetty/jetty9/javadoc,AVAILABLE}
2013-03-28 17:49:03.669:INFO:oejsh.ContextHandler:main: started o.e.j.w.WebAppContext@646dee9f{/proxy,file:/tmp/jetty-0.0.0.0-8443-xref-proxy.war-_xref-proxy-any-/webapp/,AVAILABLE}{/xref-proxy.war}
2013-03-28 17:49:03.913:INFO:oejs.ServerConnector:main: Started ServerConnector@4456cd93{SSL-npn}{0.0.0.0:8443}

在我看来,这个代理服务器可以将 spdy 转换为 http 并将其代理到目标服务器。

我现在无法测试它,因为我不知道如何使用 java 客户端(不在浏览器中)与代理服务器通信。我用谷歌搜索了我的问题,但什么也没找到,这里有什么建议吗?

【问题讨论】:

    标签: java jetty spdy


    【解决方案1】:

    使用原始 SPDY 不同于您以前可能做过的任何事情。

    话虽如此,Jetty 9 中有单元测试使用 Jetty 的SPDYClient 来测试它自己对 SPDY 的支持。他们可能会帮助你。

    http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-spdy/spdy-http-server/src/test/java/org/eclipse/jetty/spdy/server/proxy/ProxySPDYToHTTPTest.java

    【讨论】:

      猜你喜欢
      • 2013-05-02
      • 2012-11-24
      • 1970-01-01
      • 2012-06-10
      • 2012-08-21
      • 1970-01-01
      • 2017-07-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多