connection failed between Linux and Windows

Help
2012-03-06
2016-08-04
  • Clendon Gibson

    Clendon Gibson - 2012-03-06

    I am trying to use OpenOPC to communicate between a Linux client. (Redhat 5.2) and a Matrikon Simulation server on a Windows XP machine.

    When I make the OpenOPC.open_client call, I get the following error.

    # python
    Python 2.7.2 (default, Mar  5 2012, 11:43:15)
    on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import OpenOPC
    >>> opc=OpenOPC.open_client('192.168.3.5')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "OpenOPC.py", line 129, in open_client
        return server_obj.create_client()
      File "/opt/python2.7/lib/python2.7/site-packages/Pyro-3.15-py2.7.egg/Pyro/core.py", line 381, in __call__
        return self.__send(self.__name, args, kwargs)
      File "/opt/python2.7/lib/python2.7/site-packages/Pyro-3.15-py2.7.egg/Pyro/core.py", line 455, in _invokePYRO
        self.adapter.bindToURI(self.URI)
      File "/opt/python2.7/lib/python2.7/site-packages/Pyro-3.15-py2.7.egg/Pyro/protocol.py", line 290, in bindToURI
        raise ProtocolError('connection failed')
    Pyro.errors.ProtocolError: connection failed
    >>>

    If I follow the above commands from a command console locally on the windows machine, it connects fine. (I can get a list of running servers.)

    I am guessing that the OpenOPC Gateway needs some permission or to have a port opened up or something.

    The firewall is off on the windows machine. Both machines can ping each other.

     
  • Clendon Gibson

    Clendon Gibson - 2012-03-06

    I have also tried this with a Windows XP client machine. I get the same error.

    In other words, it is not a Linux issue.

     
  • SpinelliCreations

    from  your error output, it looks like the openopc clinet cannot connect to the openopc gateway running on the opc server machine.  openopc is a 2-part item… you have to have the openopc-gatewayservice running on the windows-based opc server machine.  then, you can run the openopc client instance (some program you write where you import openopc library and then connect - as you showed in example) running on windows / linux / whatever.  for testing, disable the firewall on both machines, make sure the openopc gateway service is running on the opc server machine, and then try again.

     
  • Clendon Gibson

    Clendon Gibson - 2012-03-06

    I double checked and confirmed that the OpenOPCService.exe appears in the task manager on the server and that the firewall is disabled on the server machine and the windows client machine I tried earlier.

    I tried it again with this setup, in case the service was not running before, and got the same error.

     
  • Clendon Gibson

    Clendon Gibson - 2012-03-06

    More information:

    If I try to do this locally with 'localhost' it works. If I do this locally with the IP address of the server, it fails with the previously given error message.

    Why would localhost work and the local IP address fail?

     
  • Andy Lawton

    Andy Lawton - 2012-03-15

    Does the OpenOPC service bind to all the network adapters in a PC, or just to the first one it finds?

     
  • SpinelliCreations

    I know there's supposed to have been a fix for the multiple interface issue - but I never really felt confident with it.

    I typically advise running OpenOPC in a virtual machine (Win XP or Server 2003) with 4 GB of memory - swap/virtual memory disabled - and 2 processor cores. 

     
  • Clendon Gibson

    Clendon Gibson - 2012-03-19

    The PC which is acting as the server does have several network interfaces defined. I have disabled all but the one I actually use and still have the problem. So I have 2 questions.

    How can I tell which interface(s) that the OpenOPC Gateway Service is bound to?

    How would I remove/disable the other interfaces so this was not an issue?

     
  • mwopata

    mwopata - 2012-03-22

    I'm having exactly the same problem here.

    I think that this is a bug with using the IP address instead of the localhost test on version 1.2.0 specifically. When you use the previous version of OpenOPC 1.1.6 and you type in the IP address, the connection works fine.

    Has anyone figured out a way around this?

     
  • SpinelliCreations

    I'm sure Barry would disagree with me - but from my perspective (emphasis on 'perspective') there isn't a lot of difference between 1.1.6 and 1.2.0.  For now, I'd revert to 1.1.6 and suggest you write Barry an email (barrybb@gmail.com) with a link to this thread.  If there is a legit issue, I'm sure he'll fix it - or give you a useable workaround. 

     
  • Barry Barnreiter

    In OpenOPC 1.2.0 you can solve this problem by setting system environment variable OPC_GATE_HOST equal to the IP address of the interface you want the Gateway Service to listen on.   Then re-start the Gateway Service for it to pick up the new setting.

    The OPC_GATE_HOST setting was added in 1.2.0 in order to support machines that have multiple ethernet interfaces.  By setting this you can specify which interface the Gateway Service listens on.   But unfortunately due to an oversight on my part, the default value for OPC_GATE_HOST supplied by the installer sets it to localhost.  Thus until you specifically set OPC_GATE_HOST your Gatetway Service will only be listening on 127.0.0.1.

    In the next release of OpenOPC I will add a new feature where you can specify OPC_GATE_HOST as "*" thus telling it to a listen on all interfaces.  This will be the default supplied by the installer.  But for now, just set it manually to be your box's IP addresses.

     
  • Ross McCOrmick

    Ross McCOrmick - 2012-09-18

    Apparently the linux command-line client requires python > 2.7.1. I have been able to make connections from an Ubuntu 12.04 machine with python 2.7.3 so far.  Also, the command line client doesn't work unless called from within the python interpreter. There is no 'shebang' line in the script as provided.

    I will update when I do a few more trials.

     
  • SpinelliCreations

    it does not require 2.7. 

    openopc is very happy with python 2.6 series.  and there is no linux command line client.  the issue here is your understanding of an interpreted programming language versus a scripting language.

    python is interpreted programming - it looks like a script but runs like a program, without needing to be compiled.  openopc is a library that makes opc communication possible across linux / windows / mac / any platform.  you have to write an application to use that library and "make it do what you want it to".

     
  • Ross McCOrmick

    Ross McCOrmick - 2012-09-19

    Perhaps my use of the term 'command line client' is not truly appropriate as applied to the opc.py script in Linux. However, I was able to use opc.py quite successfully as a 'command line client' in OpenOPC version 1.1.6. All the commands listed in the command line client document performed as expected.
    The only reason I needed to upgrade to OpenOPC 1.2.0 is the multiple network interface issue. Since upgrading my Windows XP OPC server to use the OpenOPC gateway service, I have had no success establishing a connection from the opc.py (also upgraded to 1.2.0) script on my Linux client PC.
    As a test, I created a virtual machine with the same configuration as my Linux client, then started applying system upgrades until the opc.py script worked. My original linux client is an Ubuntu 11.04 server, which uses python 2.7.1. The upgrade than allowed opc.py to make the connection was up to Ubuntu 12.04, which includes python 2.7.3.
    Since you say that OpenOPC is happy with pythin 2.6, perhaps there is some other requirement I am missing, and for which I have found no documentation. I am open to any suggestions or advice.

    Thanks

     
  • SpinelliCreations

    pyro… you need to have pyro installed on the client machine, regardless of whether it is windows or linux or max or whatever.  what actual error do you get in 2.6 when it craps out ?

     
  • Ross McCOrmick

    Ross McCOrmick - 2012-09-19

    From my Ubuntu 11.04 client, with python 2.6.5, I use the command 'python opc.py -m open -H aaa.bbb.ccc.ddd -h aaa.bbb.ccc.ddd -q' where aaa.bbb.ccc.ddd is the IP of the Windows XP machine running the OPC server and OpenOPC Gateway Service.

    I get the error 'Cannot connect to OpenOPC Gateway Service at aaa.bbb.ccc.ddd:7766 - incompatible protocol version'.

    It works correctly when I use the same command from the Ubuntu 12.04 client, with python 2.7.3.

    From other posts in this forum, I gather that Pyro is indeed the issue, but I have confirmed that the pyro package from the Ubuntu repository is installed. I even removed and reinstalled it to be sure. Apparently it is different from the later packages included in Ubuntu 12.04, or there is some other missing dependency.

     
  • SpinelliCreations

    try just this on your linux with python 2.6 client…

    open up a linux terminal / command prompt and type as follows….

    # cd /directory-where-you-extracted-openopc-to/src
    # python
    >>> import Pyro
    >>> import OpenOPC
    >>> opc = OpenOPC.open_client('ip-address-of-your-windows-box-running-gateway-service')

    and let us know what error (if any) it kicks back…

     
  • Ross McCOrmick

    Ross McCOrmick - 2012-09-19

    >>> opc = OpenOPC.open_client('192.168.156.145')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "OpenOPC.py", line 129, in open_client
        return server_obj.create_client()
      File "/usr/lib/pymodules/python2.6/Pyro/core.py", line 384, in __call__
        return self.__send(self.__name, args, kwargs)
      File "/usr/lib/pymodules/python2.6/Pyro/core.py", line 458, in _invokePYRO
        self.adapter.bindToURI(self.URI)
      File "/usr/lib/pymodules/python2.6/Pyro/protocol.py", line 250, in bindToURI
        authChallenge=self.recvAuthChallenge(conn)
      File "/usr/lib/pymodules/python2.6/Pyro/protocol.py", line 226, in recvAuthChallenge
        ver,body,pflags = self.receiveMsg(conn)
      File "/usr/lib/pymodules/python2.6/Pyro/protocol.py", line 561, in receiveMsg
        raise ProtocolError(msg)
    Pyro.errors.ProtocolError: incompatible protocol version
    >>>

     
  • SpinelliCreations

    ok - version of pyro running on your 2.6 python machine is too old for the version of pyro that the gateway was compiled against.  so you don't need 2.7 python, you just need some newer version of pyro that'll run with the 2.6 python.  you'll probably have to compile from source.

     
  • Ross McCOrmick

    Ross McCOrmick - 2012-09-19

    That's about what I had guessed. The non-working client uses Pyro v 3.9.7, the working client has Pryo 3.14. I hate to compile from source on a machine that uses debian packages, but I suppose I will have to. Do you know what version of Pyro was used for the gateway server?

     
  • Ross McCOrmick

    Ross McCOrmick - 2012-09-19

    SOLVED:
    'apt-get remove pyro' to rid the system of the outdated version.
    'apt-get install python-pip' to install the python package manager.
    'pip install pyro' to install the latest pyro (3.16), and now the opc.py script appears to work.

    Thanks for the assistance.

     
  • SpinelliCreations

    no sweat, glad to help.

     
  • Pradeep Reddy Vanga

    Hello,
    I am not able to connect to opc gateway service from outside the network.

    OpenOPC 1.3.1
    I have gateway service running on the same host as that OPC Server.
    netstat -an shows its listening on 0.0.0.0
    I can connect to this from a Linux box which is on the same network using public IP
    however, netstat -an shows that connection is established to local IP of gateway service rather than public ip

    If I try to connect from a Linux box which is outside the network of gateway service,
    open_client('public_ip_of_gateway') succeeds but opc.servers() fails with this error
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python2.7/site-packages/Pyro/core.py", line 381, in call
    return self.send(self.name, args, kwargs)
    File "/usr/lib/python2.7/site-packages/Pyro/core.py", line 455, in _invokePYRO
    self.adapter.bindToURI(self.URI)
    File "/usr/lib/python2.7/site-packages/Pyro/protocol.py", line 330, in bindToURI
    raise ProtocolError('connection failed')
    Pyro.errors.ProtocolError: connection failed

    netstat has this
    tcp 0 1 172.31.28.140:60928 192.168.1.15:7766 SYN_SENT
    why is it sending packets to local ip of gateway service?

    Thanks,
    Pradeep.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks