Connecting Python OpenOPC Client from ONE Windows System to OPC DA Server running on another Windows System in an INTRANET|Classic OPC: DA, A&E, HDA, XML-DA, etc.|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Connecting Python OpenOPC Client from ONE Windows System to OPC DA Server running on another Windows System in an INTRANET
Avatar
Rajnish Vishwakarma Vishwakarma
New Member
Members
Forum Posts: 2
Member Since:
05/06/2020
sp_UserOfflineSmall Offline
1
05/13/2020 - 04:35
sp_Permalink sp_Print

Hi ,

We have a  OPC DA Server running on one  Windows PC  and OpenOPC Python client running on different Windows PC .

When i am using :

Code 1:

import OpenOPC

opc=OpenOPC.open_client('X.X.X.X')

ser=opc.servers()

print(ser)

I am  getting - errors as below :

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pyro4\core.py", line 515, in connect_and_handshake
    sslContext=sslContext)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pyro4\socketutil.py", line 307, in createSocket
    sock.connect(connect)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\OPCAccess(1).py", line 8, in <module>
    opc=OpenOPC.open_client('10.36.93.149')
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\OpenOPC.py", line 131, in open_client
    return server_obj.create_client()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pyro4\core.py", line 275, in __getattr__
    self._pyroGetMetadata()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pyro4\core.py", line 615, in _pyroGetMetadata
    self.__pyroCreateConnection()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pyro4\core.py", line 596, in __pyroCreateConnection
    connect_and_handshake(conn)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pyro4\core.py", line 549, in connect_and_handshake
    raise ce
Pyro4.errors.CommunicationError: cannot connect to ('10.36.93.149', 7766): [WinError 10061] No connection could be made because the target machine actively refused it

AND  when i am connecting using the code below :

Code 2:

import OpenOPC

pywintypes.datetime = pywintypes.TimeType

opc=OpenOPC.client('X.X.X.X')

ser=opc.servers()

print(ser)

I  am getting errors as :

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\OpenOPC.py", line 167, in __init__
    self._opc = win32com.client.gencache.EnsureDispatch(c, 0)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\win32com\client\gencache.py", line 527, in EnsureDispatch
    disp = win32com.client.Dispatch(prog_id)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\OPCAccess.py", line 8, in <module>
    opc=OpenOPC.client('10.36.93.149')
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\OpenOPC.py", line 173, in __init__
    raise OPCError(error_msg)
OpenOPC.OPCError: Dispatch: Invalid class string

AND when i am using the below code

Code 3:

import OpenOPC

opc=OpenOPC.open_client('X.X.X.X')
print(opc)
ser=opc.servers()

print(ser)

I am getting error as :

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pyro4\core.py", line 515, in connect_and_handshake
    sslContext=sslContext)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pyro4\socketutil.py", line 307, in createSocket
    sock.connect(connect)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\OPCAccess(1).py", line 6, in <module>
    opc=OpenOPC.open_client('10.36.93.149')
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\OpenOPC.py", line 131, in open_client
    return server_obj.create_client()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pyro4\core.py", line 275, in __getattr__
    self._pyroGetMetadata()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pyro4\core.py", line 615, in _pyroGetMetadata
    self.__pyroCreateConnection()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pyro4\core.py", line 596, in __pyroCreateConnection
    connect_and_handshake(conn)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pyro4\core.py", line 549, in connect_and_handshake
    raise ce
Pyro4.errors.CommunicationError: cannot connect to ('10.36.93.149', 7766): [WinError 10061] No connection could be made because the target machine actively refused it

Code 4:

import OpenOPC

opc=OpenOPC.client()
ab=opc.connect('OPCDA Server ' , 'X.X.X.X')
print('Status ',ab)

 

Remember :
**
OpenOPC client is running on ONE  Windows System in a OT Network

OPC DA server is running on SECOND  Windows in a IT Network

But both Windows systems are connected in same network using a switch.**

**
If anyone of you can assist me on this .**

Thanks
Rajnish Vishwakarma

Avatar
Sergey Rukavishnikov
New Member
Members
Forum Posts: 1
Member Since:
09/17/2020
sp_UserOfflineSmall Offline
2
11/01/2021 - 19:20
sp_Permalink sp_Print sp_EditHistory

Hi! If it still usefull. I did not read whole your post attentively, but i thing all these errors can be caused by incorrect setup of remote OPC DA.  May be this link will be able to help setup DCOM https://www.kepware.com/getatt.....e-DCOM.pdf Also you can check correctness of remote OPC DA configuration on client. Try connect to your OPC DA remote server with Matrikon OPC Explorer. This utility is free and it will help you to sure that all settings are correct. If the connection fails, check configuration of DCOM and firewall. If firewall is ON, check that port 135 and dinamic ports 49152-65535 are open.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 44
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1435
Posts: 4855