AdvancedHMI Software

General Category => Support Questions => Topic started by: mreighteen on January 24, 2024, 08:44:21 AM

Title: uncatchable System.Net.Sockets.SocketException thrown when trying to read tag
Post by: mreighteen on January 24, 2024, 08:44:21 AM
I'm using the ClxDriver and I create a new connection like this:

Code: [Select]
_CLXDriver = new ClxDriver.EthernetIPforCLX
{
CIPConnectionSize = 508,
DisableMultiServiceRequest = false,
DisableSubscriptions = false,
IPAddress = ClientIP,
PollRateOverride = 500,
Port = 44818,
ProcessorSlot = 0,
RoutePath = null,
Timeout = 4000,
UseOmronRead = false
};

I wan't to make a class that automatically connects to the PLC when it is available, keeps retrying to connect when the PLC is not available and publishes an event when the connection changes. I subscribe to the following events:

Code: [Select]
           
_CLXDriver.ConnectionEstablished += OnConnectionEstablished;
_CLXDriver.ComError += OnConnectionLost;
_CLXDriver.ConnectionClosed += OnConnectionClosed;

The problem is that "ConnectionEstablished" does not fire if there is no Read called. So just creating the "ClxDriver.EthernetIPforCLX" object and waiting for "ConnectionEstablished" to fire whenever the PLC is booted up doesn't work since it never fires. If I do a read when the PLC is booted up it does fire, but if I do a read when the PLC is not booted up, an unhandled "System.Net.Sockets.SocketException" is thrown that I cannot catch since it is thrown on a different thread. So how can I know when the PLC is connected and how can I wait indefinately for a PLC to connect to?

Thnx!
Title: Re: uncatchable System.Net.Sockets.SocketException thrown when trying to read tag
Post by: Archie on January 24, 2024, 07:35:59 PM
What version of the ClxDriver are you using? I want to make sure I test in the same version because an un-catchable exception should not be thrown.
Title: Re: uncatchable System.Net.Sockets.SocketException thrown when trying to read tag
Post by: mreighteen on January 25, 2024, 07:47:23 AM
The version of the dll is 1.2.5.0 when I look at the properties.
Title: Re: uncatchable System.Net.Sockets.SocketException thrown when trying to read tag
Post by: Archie on January 25, 2024, 08:13:30 AM
The version of the dll is 1.2.5.0 when I look at the properties.
That's quite an older version. If you email sales at advancedhmi.com, and give your order number or email in which it was registered, you can get the latest version that won't give an exception.
Title: Re: uncatchable System.Net.Sockets.SocketException thrown when trying to read tag
Post by: mreighteen on January 30, 2024, 01:48:13 PM
That's good to know. I will get the latest version and try again. I post here if the new version works for me.

Thank you for the advice!
Title: Re: uncatchable System.Net.Sockets.SocketException thrown when trying to read tag
Post by: mreighteen on March 06, 2024, 04:09:16 AM
Hi,

I updated the driver to version 1.3.4.0 however, the unhandled exception still occurs. I've created a minimal working example. What's the best way to send this to you without sharing the dll publicly?

Thanks!
Title: Re: uncatchable System.Net.Sockets.SocketException thrown when trying to read tag
Post by: Archie on March 06, 2024, 12:30:01 PM
Send it to the sales at advancedhmi.com email.