-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[inputs.opcua] Panic on sudden disconnect #10595
Comments
Hi, When you tried to reproduce this with the client library what version of the library did you use? Were you using the same v0.2.3 Telegraf uses? To break down the last three calls that were made:
This is the last call from Telegraf code and it is from here. Telegraf is attempting to disconnect and calls the OPC UA library close function.
We are now outside telegraf in the OPC UA client.go also trying to close the connection.
The final line of code in the trace is the UACP connection close. The path has had a few updates, including one only a couple of days ago, which is why I was interested in what version of the library you used. Thanks! |
I tried both v0.2.3 and the latest v0.3.1, same result. The example does not panic since it does not call telegraf/plugins/inputs/opcua/opcua_client.go Lines 546 to 553 in 8610b5e
We assume that if we get an error, we still need to close the connection manually, while it is probably already closed. The error set by o.getData() matches the error from the example. A possible solution is to not close the client at all or create an issue at the opcua library to add a check for c.conn != nil at: https://github.com/gopcua/opcua/blob/486ed60873a3c6ae265036adc18d0ea7280e8663/client.go#L588
|
@magiconair what do you think about this issue? I am inclined to request that this get fixed upstream, but if you think Telegraf should not try to disconnect, we can also make that change. Thanks! |
I am of the opinion that this should be done in the library as others could run into this very issue. I have put up gopcua/opcua#562 (after fighting some weird spacing tab/space issue). |
I've merged the fix today and released https://github.com/gopcua/opcua/releases/tag/v0.3.3 |
Thank you! |
@powersj should we open a pull request to update gopcua to v0.3.3? In the current state the issue is not really fixed from the Telegraf perspective. |
@R290 please do |
Relevant telegraf.conf
Logs from Telegraf
System info
Telegraf 1.21.3, Ubuntu 20.04.3, Docker 20.10.12
Docker
Steps to reproduce
docker-compose up -d
docker kill opcua
The
docker kill
is meant to mimic a sudden disconnect event. This could also be something physical like unplugging a network cable.Expected behavior
Doing something similar using the
regread.go
example from github.com/gopcua/opcua does not result in panic and shows the following error:Actual behavior
Panic, see the Telegraf log.
Additional info
The cause is probably somewhere in the code of the Telegraf plugin since the panic is not reproducible with the example from the gopcua library.
The text was updated successfully, but these errors were encountered: