扩散连接问题:无法读取HTTP响应标头



我正在使用扩散客户端5.9.14来创建与扩散服务器的外部客户端连接,以下是我创建连接的代码。

final MockCorrelationIDConnectionListener listener = new MockCorrelationIDConnectionListener(100);
    final Credentials credentials = new Credentials(props.getProperty("user"), props.getProperty("password") );
    final ServerDetails serverDetails = ConnectionFactory.createServerDetails(props.getProperty("host"));
    final ConnectionDetails connectionDetails =
            ConnectionFactory.createConnectionDetails(serverDetails);
    serverDetails.setInputBufferSize(256 * 1024);
    serverDetails.setOutputBufferSize(256 * 1024);
    serverDetails.setCredentials(credentials);
    connectionDetails.setCredentials(credentials);
    theConnection = new ExternalClientConnection(listener, connectionDetails);
    // Connect, subscribing to a single topic
    theConnection.connect("PRICING");

这是connectors.xml文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><connectors>
 <connector name="External Client Connector">
    <type>client</type>
<api-type>classic</api-type>
    <port>3097</port>
    <acceptors>2</acceptors>
    <backlog>1000</backlog>
    <socket-conditioning>
      <input-buffer-size>127k</input-buffer-size>
      <output-buffer-size>127k</output-buffer-size>
      <keep-alive>true</keep-alive>
      <no-delay>true</no-delay>
      <reuse-address>true</reuse-address>
    </socket-conditioning>
    <system-ping-frequency>57s</system-ping-frequency>
  </connector>
  <connector name="Public HTTP Connector">
    <type>client</type>
    <api-type>classic</api-type>
    <host>253.253.253.253</host>
    <port>9500</port>
    <acceptors>2</acceptors>
    <backlog>1000</backlog>
    <socket-conditioning>
      <input-buffer-size>127k</input-buffer-size>
      <output-buffer-size>127k</output-buffer-size>
      <keep-alive>true</keep-alive>
      <no-delay>true</no-delay>
      <reuse-address>true</reuse-address>
    </socket-conditioning>
    <web-server>default</web-server>
    <policy-file>../etc/FlashPolicy.xml</policy-file>
    <system-ping-frequency>57s</system-ping-frequency>
  </connector>
  <connector name="Private HTTP Connector">
    <type>client</type>
    <api-type>classic</api-type>
    <host>10.10.10.10</host>
    <port>9500</port>
    <acceptors>2</acceptors>
    <backlog>1000</backlog>
    <socket-conditioning>
      <input-buffer-size>127k</input-buffer-size>
      <output-buffer-size>127k</output-buffer-size>
      <keep-alive>true</keep-alive>
      <no-delay>true</no-delay>
      <reuse-address>true</reuse-address>
    </socket-conditioning>
    <web-server>default</web-server>
    <policy-file>../etc/FlashPolicy.xml</policy-file>
    <system-ping-frequency>57s</system-ping-frequency>
  </connector>
</connectors>

运行代码时,我会收到以下错误

17:26:56.212 [main] INFO  c.l.a.t.MockCorrelationIDConnectionListener - Initialised Queue with capacity:100
17:26:56.328 [client multiplexer] INFO  c.p.d.m.impl.AbstractMultiplexer - Multiplexer 'client multiplexer' started.
17:26:56.345 [main] DEBUG c.p.d.io.nio.AbstractUnifiedSelector - selector 0: INITIAL -> RUNNING
17:26:56.358 [selector 0] DEBUG c.p.d.io.nio.AbstractUnifiedSelector - Starting selector with parameters selectNow()
17:26:56.375 [main] INFO  c.p.d.c.c.SocketChannelFactory - Outbound Connection: Requested output buffer size could not be allocated, requested: 256K allocated: 127K, 1023 bytes.
17:26:56.375 [main] INFO  c.p.d.c.c.SocketChannelFactory - Outbound Connection: Requested input buffer size could not be allocated, requested: '256K' allocated: '127K, 1023 bytes'.
Exception in thread "main" com.pushtechnology.diffusion.api.APIException: Connection attempt failed
    at com.pushtechnology.diffusion.api.internal.ServerConnectionImpl.connect(ServerConnectionImpl.java:472)
    at com.pushtechnology.diffusion.api.internal.ServerConnectionImpl.connect(ServerConnectionImpl.java:341)
    at com.pushtechnology.diffusion.api.client.ExternalClientConnection.connect(ExternalClientConnection.java:226)
    at com.lbg.arena.test.ClientApplication.<init>(ClientApplication.java:49)
    at com.lbg.arena.test.Wrapper.main(Wrapper.java:15)
Caused by: com.pushtechnology.diffusion.comms.connection.ConnectionException: Unable to read HTTP response headers
    at com.pushtechnology.diffusion.comms.connection.AbstractHTTPOutboundHandshake.readHttpHeaders(AbstractHTTPOutboundHandshake.java:119)
    at com.pushtechnology.diffusion.comms.http.HTTPDuplexClientOutboundHandshake.processResponse(HTTPDuplexClientOutboundHandshake.java:245)
    at com.pushtechnology.diffusion.comms.connection.AbstractHTTPOutboundHandshake.connect(AbstractHTTPOutboundHandshake.java:40)
    at com.pushtechnology.diffusion.comms.connection.CascadeDriver$1.performHandshake(CascadeDriver.java:66)
    at com.pushtechnology.diffusion.comms.connection.CascadeDriver.cascade(CascadeDriver.java:222)
    at com.pushtechnology.diffusion.comms.connection.CascadeDriver.beginCascade(CascadeDriver.java:169)
    at com.pushtechnology.diffusion.comms.connection.CascadeDriver.connect(CascadeDriver.java:55)
    at com.pushtechnology.diffusion.comms.connection.OutboundConnectionFactoryImpl.connectMessageChannel(OutboundConnectionFactoryImpl.java:244)
    at com.pushtechnology.diffusion.api.internal.ServerConnectionImpl.connectWithCredentials(ServerConnectionImpl.java:385)
    at com.pushtechnology.diffusion.api.internal.ServerConnectionImpl.connect(ServerConnectionImpl.java:447)
    ... 4 more*

导致错误的代码行是此

theConnection.connect("PRICING");

为什么会发生这种情况?我不确定问题是什么?我正在使用端口3097连接,主机是http://localhost:3097和ws://localhost:3097,尝试了这两个URL。

您在客户端实现的服务器中明确要求256K缓冲区。

serverDetails.setInputBufferSize(256 * 1024);
serverDetails.setOutputBufferSize(256 * 1024);

但是,服务器将缓冲区大小设置为127K。

<input-buffer-size>127k</input-buffer-size>
<output-buffer-size>127k</output-buffer-size>

另一个问题是,为什么不弃用经典API?

最新更新