连接问题,使用Siddhi与NATS服务器。

huangapple 未分类评论69阅读模式
英文:

Connection problem using Siddhi with NATS server

问题

我想使用Siddhi流处理器从NATS服务器读取消息。我已经安装了以下软件:

  • NATS服务器v2.1.6(在独立服务器上)
  • Siddhi siddhi-runner-5.1.2(作为二进制独立服务器安装在同一局域网上的另一台服务器上)
  • NATS 2.0.10的Siddhi NATS扩展,具有以下依赖项:
    protobuf-java-3.9.1.jar、java-nats-streaming-2.2.2.jar,
    jnats-2.6.5.jar(无论如何,我不使用流选项)

我使用以下Siddhi应用程序:

@App:name("TestNATS")

@source(type='nats', @map(type='text'), destination='test.message', bootstrap.servers='nats://192.168.50.173:4222')
define stream inputStream (name string, age int, country string);

@sink(type='log', prefix='LOGGER')
define stream OutputStream(name string, age int, country string);

@info(name='HelloWorldQueryNATS')
from inputStream
select name, age, country
insert into OutputStream;

当Siddhi启动时,它似乎可以无问题地连接到NATS服务器,但在初始握手之后,Siddhi会抛出以下异常

[2020-04-10 10:55:06,915] ERROR {io.siddhi.extension.io.nats.source.NATSSource} - Error while connecting to NATS server at destination: test.message
[2020-04-10 10:55:06,918] ERROR {io.siddhi.core.stream.input.source.Source} - Error on 'TestNATS'. Error while connecting to NATS server at destination: test.message Error while connecting at Source 'nats' at 'inputStream'. Will retry in '5 sec'. io.siddhi.core.exception.ConnectionUnavailableException: Error while connecting to NATS server at destination: test.message
Caused by: java.io.IOException: stan: connect request timeout

并且不断重新启动连接过程,因此在NATS服务器的日志中,我们可以看到以下消息:

cid:1 - Client connection created
cid:1 - <<-[CONNECT"lang":"java","version":"2.6.0","name":"1586508901596_66035_83044","protocol":1,"verbose":false,"pedantic":false,"tls_required":false,"echo":true}]
cid:1 - <<-[PING]
cid:1 - ->>[PONG]
cid:1 - <<-[SUB _STAN.acks.TSHykWgo2B6Lv2xW8b1Bfd 1]
...
cid:1 - Client connection closed
cid:1 - <-> [DELSUB 4]
cid:2 - Client connection created

NATS服务器与我使用Nodejs进行发布订阅应用程序的服务器相同,而且运行正常。我还尝试使用最新的Siddhi docker包,但结果相同。

可能出错的地方在哪里?

英文:

I would like to use Siddhi stream processor to read messages from a NATS server. I have installed the following software:

  • NATS server v2.1.6 (on a standalone server)
  • Siddhi siddhi-runner-5.1.2 (as a binary standalone on another server on the same LAN)
  • Siddhi extension for NATS 2.0.10, with the following dependencies:
    protobuf-java-3.9.1.jar, java-nats-streaming-2.2.2.jar,
    jnats-2.6.5.jar (anyway I don't use streaming option)

I use the following siddhi application:

@App:name(&quot;TestNATS&quot;)
	
@source(type=&#39;nats&#39;, @map(type=&#39;text&#39;), destination=&#39;test.message&#39;, bootstrap.servers=&#39;nats://192.168.50.173:4222&#39;)
define stream inputStream (name string, age int, country string);

@sink(type=&#39;log&#39;, prefix=&#39;LOGGER&#39;)
define stream OutputStream(name string, age int, country string);

@info(name=&#39;HelloWorldQueryNATS&#39;)
from inputStream
select name, age, country
insert into OutputStream;

When Siddhi starts it seems to connect with NATS server without problems, but after the initial handshake, Siddhi throws the following exception:

[2020-04-10 10:55:00,441]  INFO {org.wso2.msf4j.internal.websocket.WebSocketServerSC} - All required capabilities are available of WebSocket service component is available.

[2020-04-10 10:55:00,549]  INFO {org.wso2.msf4j.analytics.metrics.MetricsComponent} - Metrics Component is activated

[2020-04-10 10:55:00,552]  INFO {org.wso2.carbon.databridge.agent.internal.DataAgentDS} - Successfully deployed Agent Server

[2020-04-10 10:55:01,163]  INFO {org.wso2.carbon.analytics.idp.client.core.utils.IdPServiceUtils} - Enabling default IdPClient Local User Store as configuration is not overridden.

[2020-04-10 10:55:01,167]  INFO {org.wso2.carbon.analytics.idp.client.core.utils.IdPServiceUtils} - IdP client of type &#39;local&#39; is started.

[2020-04-10 10:55:06,915] ERROR {io.siddhi.extension.io.nats.source.NATSSource} - Error while connecting to NATS server at destination: test.message

[2020-04-10 10:55:06,918] ERROR {io.siddhi.core.stream.input.source.Source} - Error on &#39;TestNATS&#39;. Error while connecting to NATS server at destination: test.message Error while connecting at Source &#39;nats&#39; at &#39;inputStream&#39;. Will retry in &#39;5 sec&#39;. io.siddhi.core.exception.ConnectionUnavailableException: Error while connecting to NATS server at destination: test.message


Caused by: java.io.IOException: stan: connect request timeout

and restarts the connection process continuously, so in the logs of NATS server we can see the following messages:

cid:1 - Client connection created

cid:1 - &lt;&lt;- [CONNECT&quot;lang&quot;:&quot;java&quot;,&quot;version&quot;:&quot;2.6.0&quot;,&quot;name&quot;:&quot;1586508901596_66035_83044&quot;,&quot;protocol&quot;:1,&quot;verbose&quot;:false,&quot;pedantic&quot;:false,&quot;tls_required&quot;:false,&quot;echo&quot;:true}]

cid:1 - &lt;&lt;- [PING]

cid:1 - -&gt;&gt; [PONG]

cid:1 - &lt;&lt;- [SUB _STAN.acks.TSHykWgo2B6Lv2xW8b1Bfd 1]

cid:1 - &lt;&lt;- [SUB _INBOX.TSHykWgo2B6Lv2xW8b1BaH 2]

cid:1 - &lt;&lt;- [SUB _INBOX.TSHykWgo2B6Lv2xW8b1Bcx 3]

cid:1 - &lt;&lt;- [SUB _INBOX.4bm5CWKphBwldfvnGCxxJd.* 4]

cid:1 - &lt;&lt;- [PUB _STAN.discover.test-cluster _INBOX.4bm5CWKphBwldfvnGCxxJd.4bm5CWKphBwldfvnGCxxa9 88]

cid:1 - &lt;&lt;- MSG_PAYLOAD: [&quot;\n\x191586508901596_66035_83044\x12\x1d_INBOX.TSHykWgo2B6Lv2xW8b1BaH\x18\x01\&quot;\x16TSHykWgo2B6Lv2xW8b1BXb(\x050\x03&quot;]

cid:1 - Client Ping Timer

cid:1 - -&gt;&gt; [PING]

cid:1 - &lt;&lt;- [PONG]

cid:1 - &lt;&lt;- [UNSUB 1]

cid:1 - &lt;-&gt; [DELSUB 1]

cid:1 - &lt;&lt;- [UNSUB 2]

cid:1 - &lt;-&gt; [DELSUB 2]

cid:1 - &lt;&lt;- [UNSUB 3]

cid:1 - &lt;-&gt; [DELSUB 3]

cid:1 - Client connection closed

cid:1 - &lt;-&gt; [DELSUB 4]

cid:2 - Client connection created

The NATS server is the same I use with a pub-sub application using Nodejs and it works fine. I tried also to use the last Siddhi docker package but the result is the same.

Where could be the mistake ?

答案1

得分: 0

使用 nats-streaming-server 替代 nats-server,连接问题不再出现。
谢谢。

英文:

Using nats-streaming-server instead of nats-server, connection problem no longer occurs.
Thanks.

huangapple
  • 本文由 发表于 2020年4月10日 17:28:47
  • 转载请务必保留本文链接:https://java.coder-hub.com/61137459.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定