Skip to content
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

ModbusTcpClient .Initialize throws Exception -> hard to catch / determine what went wrong #139

Open
JaggerJo opened this issue Dec 11, 2024 · 2 comments
Labels

Comments

@JaggerJo
Copy link

Hey @Apollo3zehn 👋

First, great library - thanks for maintaining.

We are having a small problem with Initialize on the ModbusTcpClient. We want to periodically retry to connect if connecting fails. We could do that by wrapping the call to initialise in a try catch, the issue is that we'd need to catch all exceptions.

if (remoteEndpoint is not null && !tcpClient.ConnectAsync(remoteEndpoint.Address, remoteEndpoint.Port).Wait(ConnectTimeout))
throw new Exception(ErrorMessage.ModbusClient_TcpConnectTimeout);

It would be nice to throw a special kind of exception here so that we can only catch e.g. FluentModbusException instead of Exception.

What do you think?

Are we completely missing something here?

@Apollo3zehn Apollo3zehn added the v6 label Jan 2, 2025
@Apollo3zehn
Copy link
Owner

I see your point. But wouldn't a TimeoutException be more suitable?

I will put this issue on my v6 TODO list and I plan to release a breaking change release soon. Howevery I had a very turbulent year and already had to postpone it multiple times so I won't make any promises :-(

@JaggerJo
Copy link
Author

JaggerJo commented Jan 2, 2025

Hey @Apollo3zehn,

Thanks for the response.

That would work too, yes.

I maintain OSS myself, I know how it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants