GatewayHook custom functions

How do I go about adding a function like readTag(String tag) to the Gateway Hook and then use that function elsewhere in my module?

So far I tried adding the gateway scope as a dependency to the client scope, then import the GatewayHook into my component, which is all fine. However when I enter this line under my component's class:

private GatewayHook gatewayHook = new GatewayHook();

Ignition starts throwing errors:

You need to be looking at how module RPC works in the scripting example: ignition-sdk-examples/scripting-function at master · inductiveautomation/ignition-sdk-examples · GitHub

Your client and gateway code and classes are not only running in entirely different scopes, but in entirely different JVM instances.

Thanks. I will have a look at that.

For the scripting-function example, why are the MathBlackBox & AbstractScriptModule in the common scope?
Could I put those directly under the gateway scope in my project?

They're in common scope because the interface (and the abstract class; the example predates default methods in interfaces) are implemented on both sides; the client side implements via RPC, while the gateway side just implements directly.

It's a somewhat contrived example that's trying to prove a point.


I think I got it all in place now. The TagHandler interface is in the common scope, TagHandlerImpl() is right next to GatewayHook.

This is in the GatewayHook:

    public Object getRPCHandler(ClientReqSession session, String projectName) {
        return new TagHandlerImpl();

This is in my component on the client side:

private final TagHandler rpc = ModuleRPCFactory.create(

And this is the test I'm trying to run:

String str = rpc.test(jobColor);

But I'm getting the following error:

Is your module actually loading correctly on the gateway?

I think so. I was initially using the GatewayHook from the "managed-tag-provider" example in my module and it loaded correctly. It created and removed tags and loaded them with random values.

Check the module status page on the gateway. That error suggests it's not, or you've got a mismatch in your module IDs somewhere.

These are the warnings from the last time I ran Ignition. There are no errors.

Got it to work now. There was a mismatch in the moduleID

1 Like