Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

关于IsConnected连上后断线的处理请教 #9

Open
ymmemo opened this issue Jun 11, 2021 · 2 comments
Open

关于IsConnected连上后断线的处理请教 #9

ymmemo opened this issue Jun 11, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@ymmemo
Copy link

ymmemo commented Jun 11, 2021

你好,请问IsConnected()是否会因为连上后对方断线而为false?

p := gomodbus.NewTCPClientProvider("127.0.0.1:1502", gomodbus.WithAutoReconnect(0), gomodbus.WithEnableLogger())
连线上之后对方断线
tcp 127.0.0.1:60127->127.0.0.1:1502: wsasend: An established connection was aborted by the software in your host machine.
自身的IsConnected()仍为true

@thinkgos
Copy link
Member

这的确是个问题... 目前连上后就不会再置为false. 一旦调用API,将进行重试连接. 这个IsConnected() 标记和对方是通的. 后续优化一下.

目前这个库准备要改,API可能会有破坏, 所以移到了这个组织来. 旧的库还在thinkgos下. 最近暂时没有时间.

@thinkgos thinkgos added bug Something isn't working enhancement New feature or request labels Jun 11, 2021
@thinkgos
Copy link
Member

thinkgos commented Jun 11, 2021

这个问题只有TCP才会存在对端关闭, 只有tcp才会有掉线需求. 像RTU,ASCII, 没有对端关闭一说,只能通过在一定时间内的失败次数来判断掉线. 后续再思考下如果弄比较好.

@thinkgos thinkgos removed the bug Something isn't working label Jun 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants