OPC ua订阅写入或者读取某个点位直接断开连接bug

最近发现一个奇怪的事情,使用OPC UA进行通讯的时候发现,只要添加了多个点位的订阅UA_Client_runAsync(m_pClient, m_time),然后对于其中一个点位进行写操作时直接就断开连接UA_Client_writeValueAttribute(m_pClient, nodeId, myVariant)

然后就从网上找问什么,但是网上有关opc ua通讯的文章都少的可怜,大部分还都跟我之前写过了一模一样,不过功夫不负有心人,找到一篇issue,原文如下:

According to Part 4, 5.13.1.1 f, the server is required to send a keepalive after the maximum keep alive count has been reached. Depending on the settings, this could be minutes or even hours after the timeout in config.timeout.
Values for PublishingInterval and MaxKeepAliveCount are only limited by the data types used (double and UInt32). If the server permits large values, using revisedPublishingInterval*revisedMaxKeepAliveCount + config.timeout could lead to manuallySendPublishRequest blocking for a very long time in which the client can’t be used to read/write/call methods (except when sending the publish requests from another thread and using __UA_Client_AsyncService for everything else).

意思重点为:
则使用修订的PublisheringInterval * revisedMaxKeepAliveCount + config.timeout可能导致很长一段时间内手动阻止SendSendRequest的使用,导致客户端无法用于读取/写入/调用方法(除非从另一个客户端发送发布请求)线程并使用__UA_Client_AsyncService进行其他操作)。

从另一个issue中说是在最新0.3版本中已经修正,但是实在不知道0.3版本是几个意思??

索性还有另外一种办法,就是不要对使用订阅的客户端进行读写操作,直接新建两个客户端,一个用于订阅点位变化,一个用于读写操作

未经允许,禁止转载!如有有用,麻烦您给点个赞👍!!!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值