Run a gateway script on a remote Gateway

Here is the situation:
We have 2 gateways. Gateway #1 is hosted in the cloud, Gateway #2 is hosted inside the site network. They have allowed the Gateway-to-Gateway port through the firewall, but none other. The Gateway Network has been established and is communicating.

I want to run a script on the Internal gateway (gateway#2) and pass the results to gateway#1. Also, the function call should be initiated from gateway#1 by some mechanism (doesn’t quite matter at this point).

Is there a standard Ignition mechanism to do this?

Thanks

You can probably use https://docs.inductiveautomation.com/display/DOC80/system.util.sendRequest
or sendMessage

2 Likes

Thanks jpark,

Any idea what the configuration will look like on the side receiving the request? Is the messageHandler parameter the Global Function Name or do you have to set up a mechanism on the other side to “catch” the sendRequest?

-Steve

You add the handler under the message section of gateway event scripts on the receiving gateway:


The messageHandler parameter matches the gateway message handler name (“logger” in the example shown).

Thanks for the screenshot @witman

Based on the documentation, it looks like I will be able to call the message function from a Client session on Gateway #1. Would you agree?
image

@jpark

You could send it from a client, but from your initial description it sounds like you’d want to send it from the gateway, which should also work (from further down the on the documentation page):
image
The part you highlighted just specifies that there are no special client permissions required to use it from a client.

I’ll let you know how it all worked out once I implement.
Thanks

1 Like

@witman @jpark
So I got it to work from Gateway#1 to Gateway#2 in the designer Script Console, however in a runtime client I am getting this error message in the Thread Logs:
“…MessageHandlerException: User does not have required permissions…”

Any idea what setting needs to happen to appease the Security gods?
I can dump the full long error message if that will help you figure it out.

Look in the project properties dialog. There're several security limits that are default for new projects.

1 Like

Thanks for the reply @pturmel.

I set these to all to True for both GW#1 and GW#2 - still no luck

Actually, a runtime client shouldn’t matter. You should be sending the message only to gateway scope, and the handler should be under the gateway scripts, not the (Vision) client scripts.

@pturmel @jpark @witman

Got it working. I had left the Security Zone settings as non-default on GW#2, which was blocking the action in the client session.

Here is the final configuration:
Remote Message Call from GW#1 to GW#2:
def remoteRequestGetTagsValueForDate(tagsList, dt):
try:
requestReturn = system.util.sendRequest(project=‘Sandbox’, messageHandler=‘getTagsValueForDate’, payload={‘tagsList’:tagsList, ‘dt’:dt}, remoteServer=“ignition-ip-172-00-00-01”, timeoutSec=10000)
return requestReturn
except:
return “Error running global function”

Message Handler config on GW#2:
image

Global Script defined on GW#2:
def getTagsValueForDate(tagsList, dt):

1 Like