Проблема с диффузионным соединением: невозможно прочитать заголовки ответа 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.

1 ответ

Вы явно запрашиваете 256 Кб буферов с сервера в вашей клиентской реализации.

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

Однако сервер установил размер буфера 127 КБ.

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

Другой вопрос: зачем использовать Classic API, если он устарел?

Другие вопросы по тегам