Connection is made to the OPC server (via local network) through OpenOPC .

The problem is that after several requests for receiving data, they cease to arrive and a timeout error occurs.

So far I have noticed that only restarting the OPC-server service helps. But not for long, the problem repeats.

Who faced how to deal with it?

(DCOM was not configured and is not considered yet, but if nothing is decided, it is necessary to organize a connection through DCOM)

    2 answers 2

    There was the same situation. Because there were no error messages, I turned on the "get error message" option: include_error=True . After this exchange earned without fail. Without this option takes off on timeout . Code example:

     import OpenOPC import time opc = OpenOPC.client() # узнаем список доступных серверов server=opc.servers() print server # выбираем третий из списка server=server[2] print ("Connect to Server: " + server) # подключемся к серверу opc.connect(server) # создаем список опрашиваемых регистров для прибора Owen MB110-8A tagsValue=[]; tagsStatus=[]; for each in range(1,9): tagsValue.append(u'Node1.MB110-8A.Input'+str(each)+'.Value') # регистры значений tagsStatus.append(u'Node1.MB110-8A.Input'+str(each)+'.Status') # регистры статуса # инициализируем группы опроса opc.read(tagsValue,group='value',update=1,include_error=True) opc.read(tagsStatus,group='status',update=1,include_error=True) # в тестовой программе я опрашивал регистры 100 раз i=0 while i<100: # считываем значения data=opc.read(group='value',update=1, include_error=True) statusList=opc.read(group='status',update=1, include_error=True) # парсим данные, форматируем и выводим в консоль j=0 temp=list() messages=list() while j<(len(data)-0): adress,value,answ,clock,Message=data[j] adress,status,answ,clock,Message=statusList[j] #print status if (status==0): temp.append(value) else: temp.append(0); messages.append(Message) j+=1 j=0 text=''+clock+"-> " while j<len(temp): text+= ("{t}").format(t="%6.1f"%(temp[j]))#+messages[j]+"\n" j+=1 print text i+=1 time.sleep(3) # отключаемся opc.close() 
    • An interesting option, but unfortunately I can’t check it out anymore_) - ivan K.

    As a result, it turned out that the OPC-server accepts received requests for polling, and if a new request is made, and the data has not been updated by that time, the timeout will occur. In order to avoid this, it is imperative to remove the requested tags from the survey. The only way that we managed to find and check is to add a group or groups during the survey and after you have received all the data, delete the groups. After that, the OPC-server will clear the polls of your tags from its module.