Gateway stops when OPC server stops

Questions regarding installing, running and configuring UaGateway.

Moderator: uagateway

Post Reply
cs_lf
Jr. Member
Jr. Member
Posts: 4
Joined: 03 Jul 2017, 08:27

Gateway stops when OPC server stops

Post by cs_lf »

Hello,

we are currently evaluating various OPC DA <-> OPC UA gateways (to connect a legacy OPC DA server) for a customer project.

We have run into an issue with the UaGateway: the OPC-DA application we are wrapping is a GUI application (in dcomcnfg.exe we set the application to be started as "interactive user" to get it to work), and once a user is logged in, the OPC-DA server is automatically started (via (D)COM's autolaunch feature) - so far so good. UA requests are properly tunneled to the underlying application.

However, if a user on the machine exits the application via the GUI, UaGateway also stops. If one restarts the gateway manually, the GUI application will also be restartet. However, if one just restarts the GUI application (as a user might to if they accidentally closed it), the UaGateway remains off.

Is there a reason why the gateway stops when an underlying OPC-DA server stops? Is there a configuration option to change that behavior? Ideally we'd like UaGateway to simply restart the OPC-DA server if it stops, and continue running. Alternatively we'd also be happy with a solution where the UaGateway is automatically restarted after it ends for this reason.

Many thanks!

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: Gateway stops when OPC server stops

Post by Support Team »

Hello,

this sounds strage. The underlying COM DA Server fires a "shutdown" event when being shutdown gracefully. The UaGateway waits for 60 seconds and will than try to reconnect (and by this restart) the underlying COM DA Server. When underlying COM DA Server was "killed" (without being able to properly fire his shutdown event) the UaGateway enters a reconnect loop after 5-15 seconds depending on its watchdog.

If you restart the UaGateway the underlying COM DA Server is (initially) connected (has nothing to do with the reconnect).

The UaGateway never "stops" it always runs, and it always tries to "reconnect" the underlying DA Server. However just the wait-time is different before trying it (graceful / ungraceful shutdown). Reason is that on a gracefull shutdown the User may have some good cause to restart (e.g. reconfiguation) the unerlying DA Server, and UaGateway should not be so "aggressive". On an ungraceful shutdown the UaGateway assumes "connection loss" and enters into its standard reconnect loop.

Make sure you waited long enough (60 sec) to observer the UaGateway reconnecting after the graceful shutdown of COM DA Server.
Best regards
Unified Automation Support Team

cs_lf
Jr. Member
Jr. Member
Posts: 4
Joined: 03 Jul 2017, 08:27

Re: Gateway stops when OPC server stops

Post by cs_lf »

Hello,

thank you for your response. What you describe is what I expected to happen, but unfortunately it is not what actually happens.

Current configuration:
  • Windows 7
  • UaGateway Product version: V1.4.4 357
  • Demo version of UaGateway configured to automatically start in background
  • dcomcnfg.exe: specific OPC server configured to run as interactive user
When I boot the system and the login, once I see the desktop, the GUI application with the integrated OPC server is started in the background. So far everything works as expected.

However, when I close the GUI application, the UaGateway also terminates (this can be seen in the task bar icon that switches from green to red). Even after 10 minutes the gateway didn't restart automatically.

I enabled the trace, and the following lines are the lines that appear at the end of the log file (all log lines before that have a timestamp that is quite a bit before I closed the application). (Note that I manually removed the OPC server name for legal reasons, but otherwise didn't modify the logfile before posting it.)

Code: Select all

08:38:59.318Z|4|0850* ==> OPCShutdown::ShutdownRequest
08:38:59.318Z|3|0850* ShutdownRequest - reason for shutdown: 
08:38:59.318Z|4|0850* <== OPCShutdown::ShutdownRequest [hr=S_OK]
08:38:59.318Z|4|0BD4* DONE IConnectionPoint::Unadvise [hr=0x0]
08:38:59.318Z|5|0BD4* Dtor OPCDataCallback
08:38:59.318Z|6|0BD4* <-- DaGroupMgt::disconnectCallback [hr=0x0]
08:38:59.318Z|6|0BD4* --> DaGroupMgtPrivate::ReleaseOPCGroupInterfaces
08:38:59.332Z|2|0A34* Lost connection to OPC Server <###############> on 
08:38:59.332Z|5|0A34* Ctor TerminateOpcThread
08:38:59.332Z|4|0A34* CALL DataCallback::ServerStatusChange
08:38:59.332Z|4|0A34* DONE DataCallback::ServerStatusChange
08:38:59.332Z|6|0E34* --> TerminateOpcThread::run
08:38:59.332Z|6|0E34* --> DaServerMgt::disconnectOPCServer
08:39:00.704Z|4|0810* [uastack] OpcUa_SecureListener_ChannelManager_TimerCallback: Checking Channels for lifetime expiration!
08:39:00.717Z|6|0A4C* Object Counts:      Session        =     1
08:39:00.717Z|6|0A4C* Subscription =     0  Data MonitoredItem =     0   Event MonitoredItem  =     0 
08:39:00.717Z|6|0A4C* UaNode       =   961  UaObject           =   114   UaVariable           =   553 
08:39:00.717Z|6|0A4C* UaMethod     =    63  UaView             =     0   UaReferenceType      =    27 
08:39:00.717Z|6|0A4C* UaObjectType =    84  UaVariableType     =    30   UaDataType           =    90 
08:39:00.720Z|3|0810* ServerMain timerCallback()
The Windows event log shows that the UaGateway application crashes:

Code: Select all

Faulting application name: uagateway.exe, version: 1.4.4.357, time stamp: 0x58affba5
Faulting module name: uagateway.exe, version: 1.4.4.357, time stamp: 0x58affba5
Exception code: 0xc0000005
Fault offset: 0x001cdb0a
Faulting process id: 0xa84
Faulting application start time: 0x01d2f56a1d60d9a1
Faulting application path: C:\Program Files (x86)\UnifiedAutomation\UaGateway\bin\uagateway.exe
Faulting module path: C:\Program Files (x86)\UnifiedAutomation\UaGateway\bin\uagateway.exe
Report Id: 64534ce6-615d-11e7-87c2-9506c2eb88ce
If I manually restart the UaGateway, it will restart the GUI application again.

cs_lf
Jr. Member
Jr. Member
Posts: 4
Joined: 03 Jul 2017, 08:27

Re: Gateway stops when OPC server stops

Post by cs_lf »

I just found a workaround for this: in the Windows Service settings I can configure the "UaGateway COM Server" to restart after failure after N minutes, and that works fine. So this isn't a problem for us anymore. But in case you would want to investigate this crash, I'd be happy to provide you with more details, if needed.

Thanks!

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: Gateway stops when OPC server stops

Post by Support Team »

Hello,

please send a complete log file to support@unified-automation.com. It would also be fine to know which kind of COM Server you use in this scenario (maybe you cann send us this Server, too). We will check the log files and try to find a solution.
Best regards
Unified Automation Support Team

Post Reply