gpt4 book ai didi

java - 扩散连接问题: Unable to read HTTP response headers

转载 作者:行者123 更新时间:2023-11-30 06:24:41 25 4
gpt4 key购买 nike

我正在使用扩散客户端 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,已尝试这两个网址。

最佳答案

您在客户端实现中明确向服务器请求 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 已被弃用时,为什么还要使用它?

关于java - 扩散连接问题: Unable to read HTTP response headers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47441064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com