# Modbus OPC UA devices not connecting when created by script

**URL:** <https://forum.inductiveautomation.com/t/modbus-opc-ua-devices-not-connecting-when-created-by-script/59508>\
**Category:** Ignition\
**Created:** [May 12, 2022, 3:28pm UTC](https://forum.inductiveautomation.com/t/modbus-opc-ua-devices-not-connecting-when-created-by-script/59508 "2022-05-12T15:28:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PatrickB](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@PatrickB](https://forum.inductiveautomation.com/u/PatrickB)\
**Post date:** [May 12, 2022, 3:28pm UTC](https://forum.inductiveautomation.com/t/modbus-opc-ua-devices-not-connecting-when-created-by-script/59508/1 "2022-05-12T15:28:55Z")

</div>

Perhaps the following is an undocumented feature… or have I missed something around creation of OPC UA devices through a script?

System is Ignition 8.1.10 running under Ubuntu on an AWS server.

Here’s the story, albeit in point form:

- I managed to create a script to create a set of Modbus OPC UA devices (approx 70) using system.device.addDevice.
- Everything went fine except after creation of the devices none of the script-created devices connected, instead remaining with a “disconnected” status (listed as “Enabled: true”).
- I clicked “Edit” on one, and lo-and-behold: The “enabled” setting _was_ ticked (default is true).
- I carefully checked all other parameters which were correct. Having changed nothing, I clicked “Save changes” down the bottom.
- The device immediately tried to connect and was successful (Status: Connected)
- I then proceeded to simply click “edit” then “Save changes” on each of the sites one-by-one, which all then proceeded to connect (network issues excluded) upon the “Save changes”

So my questions are:

1. Why, in spite of being added and enabled by default, did none of these sites try to connect until I simply opened and closed them?
2. Is there something I should have perhaps set in the script- nothing seems obvious in the system.device.addDevice parameters or device props?

Thanks,  
Patrick.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 12, 2022, 3:37pm UTC](https://forum.inductiveautomation.com/t/modbus-opc-ua-devices-not-connecting-when-created-by-script/59508/2 "2022-05-12T15:37:32Z")

</div>

There's a fix landing in 8.1.17 described in the release notes like this:

> Fixed a race condition that caused Modbus connections to get stuck in "Connecting" state after Ignition Gateway start/restart. The race condition was only likely to be triggered on under-powered single-core embedded hardware.

but it's possible that trying to create/start 70 at once also triggered it.

If not that, I don't know - maybe a bug? Is it repeatable?

---

<div class="post-metadata">

**Author:** ![PatrickB](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@PatrickB](https://forum.inductiveautomation.com/u/PatrickB)\
**Post date:** [May 13, 2022, 2:21am UTC](https://forum.inductiveautomation.com/t/modbus-opc-ua-devices-not-connecting-when-created-by-script/59508/3 "2022-05-13T02:21:12Z")

</div>

I will attempt to test later on, albeit without actual connections. My fading memory tells me at least on the other test servers the attempt to connect (no connection possible) was made, i.e. the status was “Connecting”.
