pyads: ADSError: ROUTERERR_PORTALREADYINUSE (1286)

Hi,

Thanks for your work on this. Do you have an insight on to why I’d be getting error 1286? My code is as follows:

pyads.open_port()
remote_ip = '192.168.1.38'
adr = pyads.AmsAddr('5.59.211.2.1.1',851)
pyads.add_route(adr,remote_ip)
plc = pyads.Connection('5.59.211.2.1.1',851)
plc.open()

In my case, 192.168.1.38 is the remote machine, with NetID 5.59.211.2.1.1.

The ‘add_route’ method returns “connected to 192.168.1.38”, but then plc.open() gives the port in use error.

I noticed the route is not in the routing table of the remote PLC… does it work on remote machines instead of 127.0.0.1.1.1? I don’t see a method for adding the password, so I’m not sure how it would work. To work around that, like I’ve done with node-ads in the past, I created a static local route to my machine from the PLC side, but I’m not able to connect, given the error above.

I’m on ubuntu with a win7 TC3 PLC.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 27 (2 by maintainers)

Most upvoted comments

Bon appétit

import pyads

AMS=‘LINUX AMS’ PLC=‘PLC IP’ USER=‘PLC_USERNAME’ PW=‘PLC_PASSWORD’ HOSTNAME=‘LINUX_IP’ PLC_AMS_ID=‘PLC_AMS’ pyads.add_route_to_plc(AMS,HOSTNAME,PLC,USER,PW)

This seems to work with my setup.

Version details:

image

I just got it to work two minutes ago! What did the trick for me was altering the add_route_to_plc command. The documentation says something like: pyads.ads.add_route_to_plc(sending_net_id, adding_host_name, ip_address, username, password, route_name=None, added_net_id=None) I filled out all the fields and switched Hostname and Routename, resulting in:

pyads.add_route_to_plc('192.168.66.53.1.1', 'Pi', '192.168.66.27', 'Administrator', '', route_name='192.168.66.53',added_net_id='192.168.66.53.1.1')
plc = pyads.Connection('5.18.105.98.1.1', pyads.PORT_SPS1, '192.168.66.27')
plc.is_open
False
plc.open()
2019-09-18T17:02:41+0200 Info: Connected to 192.168.66.27
plc.read_by_name('MAIN.Logger_OnOFF', pyads.PLCTYPE_BOOL)
True