ya-mouse / openopc

OpenOPC for Python3.4
Other
48 stars 56 forks source link

Intermittent read error occurs. Help solve the problem #27

Open DanilaX1 opened 1 year ago

DanilaX1 commented 1 year ago

Intermittent read error occurs. Help solve the problem

2023-01-18 00:00:35,292 ERROR Connect: -2146959355 Traceback (most recent call last): File "C:\Users\Freelancer\PycharmProjects\OPC_DATA\venv\lib\site-packages\OpenOPC.py", line 223, in connect self._opc.Connect(s, opc_host) File "C:\Users\FREELA~1\AppData\Local\Temp\gen_py\3.8\341A7851-5DEA-4022-B0D6-F9954AF9273Dx0x1x0.py", line 233, in Connect return self.oleobj.InvokeTypes(1610743826, LCID, 1, (24, 0), ((8, 1), (12, 17)),ProgID pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2146959355), None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Freelancer\PycharmProjects\OPC_DATA\WRdbSchedule.py", line 68, in RdAndWrOPCtoDB maplai.rdtagfor_db() File "C:\Users\Freelancer\PycharmProjects\OPC_DATA\WRdbSchedule.py", line 36, in rdtagfor_db opc.connect('Freelance2000OPCServer.51') File "C:\Users\Freelancer\PycharmProjects\OPC_DATA\venv\lib\site-packages\OpenOPC.py", line 227, in connect raise OPCError(error_msg) OpenOPC.OPCError: Connect: -2146959355

I made a script to write data to a database. Reading and writing occurs once every 5 seconds. Unfortunately, this script does not work stably for 1 or 5 days, then such an error occurs. Help find a solution

ya-mouse commented 1 year ago

The returned error is 0x80080005 (returned by DCOM on the target system). Is the error occurs on the same requests as when it runs fine or accessing different objects? This also might mean wrong CLSID, not sufficient rights and so on. You should check the windows event log on the server. If the Freelance2000OPCServer have own logs, check it also.

ya-mouse commented 1 year ago

The error 0x80020009 means invalid value.

ya-mouse commented 1 year ago

In common sense, it's better to catch exceptions, log failed attempt and retry.

DanilaX1 commented 1 year ago

I made some changes and now I'm getting the error about once a week -2147024732 windows event log constantly issues "C:\Program Files (x86)\ABB\Freelance\exe\opcsrv.exe" -51 -Embedding IOPCItemMgt::RemoveItems(): failed because group 'Come' is marked as deleted, return E_FAIL please tell me which direction to go

DanilaX1 commented 1 year ago

For a better understanding of the problem, I will give the code of the function. In it I use the read function opc.iread(self.tags) could that be the problem. I don't use 'Come' groups

 def rdtagfor_db(self):
        try:
            self.data = []
            for name, value, quality, time in opc.iread(self.tags):
                if quality == 'Good':
                    self.data.append(value)  # Для консистенции данные записываются в любом случае
                else:
                    self.data.append(0.0)
                    print(name, "is not good")
                    logging.error((name + "is not good"), exc_info=True)  # Но если ОПЦ возвращает не ГУд то пишем в лог
        except OpenOPC.TimeoutError:
            print("TimeoutError occured")
            logging.error(("TimeoutError occured"), exc_info=True)