# Error MessageHandlerManager is null in ScriptConfig!

**URL:** <https://forum.inductiveautomation.com/t/error-messagehandlermanager-is-null-in-scriptconfig/104920>\
**Category:** Module Development\
**Tags:** ignition81, perspective\
**Created:** [April 9, 2025, 6:38pm UTC](https://forum.inductiveautomation.com/t/error-messagehandlermanager-is-null-in-scriptconfig/104920 "2025-04-09T18:38:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [April 9, 2025, 6:38pm UTC](https://forum.inductiveautomation.com/t/error-messagehandlermanager-is-null-in-scriptconfig/104920/1 "2025-04-09T18:38:40Z")

</div>

I have a module with a ProjectListener.  
on Project update I send a gateway message handled by a gateway script message handler

```python
@Override
public void projectUpdated(String project) {
	if (enabled && filterProjectUpdated) {
		logger.debug("projectUpdated : {}",project);
		if (passFiterProjectNames(project)){
			notifyGateway(project,"projectUpdated");
		}
	}
}

private void notifyGateway(String project,String cause){
	try {
		synchronized(this) {
			String resultGatewayMessageProjectName;

			if (shutdownPending) {
				return;
			}

			if (projectListenerUseGatewayScriptingProject) {
				resultGatewayMessageProjectName = context.getSystemProperties().getGatewayScriptingProject();
			} else {
				if (gatewayMessageProjectName == null) {
					gatewayMessageProjectName = "";
				}
				resultGatewayMessageProjectName = gatewayMessageProjectName;
			}
			if (gatewayMessageHandler == null) {
				gatewayMessageHandler = "";
			}
			if (gatewayMessageHandler.isEmpty()) {
				logger.warn("notifyGateway() - Gateway Notification Enabled but Gateway Message Handler is not provided !");
			} else if (resultGatewayMessageProjectName.isEmpty()) {
				logger.warn("notifyGateway() - Gateway Notification Enabled but Gateway Project Name is not provided !");
			} else {
				PyDictionary messagePayload = new PyDictionary();
				messagePayload.put(new PyString("project"), project);
				messagePayload.put(new PyString("cause"), cause);
				Properties filterParams = new Properties();
				filterParams.setProperty(MessageDispatchManager.KEY_SCOPE, MessageDispatchManager.SCOPE_GATEWAY_ONLY);
				logger.debug("notifyGateway() - Gateway Notification : projectName={}, gatewayMessageHandler={}, messagePayload={}",
						resultGatewayMessageProjectName, gatewayMessageHandler, messagePayload);
				context.getMessageDispatchManager().dispatch(resultGatewayMessageProjectName, gatewayMessageHandler, messagePayload, filterParams);
			}
		}
	} catch (Exception e) {
		logger.error("notifyGateway() - exception : ", e);
	}
}

```

when I import a project (containing the script executed by the gateway message handler)  
I've **sometimes** have the following error, and as a side effect it seems that all tags expression with runscript are broken...and I need to restart the gateway

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/7/d725422d57641c206ba4a43a8f133eb2e6ff75d5.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 9, 2025, 7:28pm UTC](https://forum.inductiveautomation.com/t/error-messagehandlermanager-is-null-in-scriptconfig/104920/2 "2025-04-09T19:28:42Z")

</div>

You are racing with the Project Script Manager, which also listens for project changes in order to restart script modules. You simply should not be generating this message. A project script can tell when its underlying project starts up by implementing a startup event. That will always fire in a non-racy way.

Some things are not meant to be done by SDK modules.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [April 9, 2025, 7:48pm UTC](https://forum.inductiveautomation.com/t/error-messagehandlermanager-is-null-in-scriptconfig/104920/3 "2025-04-09T19:48:33Z")

</div>

I Believe that the startup script was fired each time some change are saved in scripts.  
I want to process only on project import.  
Perhaps I could add a delay before sending the gateway message. Not a good way to make some synchonization but a workaround...

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 9, 2025, 7:52pm UTC](https://forum.inductiveautomation.com/t/error-messagehandlermanager-is-null-in-scriptconfig/104920/4 "2025-04-09T19:52:40Z")

</div>

> [@mazeyrat](#):
>
> want to process only on project import.

How are you determining this? Diving into project change diffs?

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [April 9, 2025, 7:59pm UTC](https://forum.inductiveautomation.com/t/error-messagehandlermanager-is-null-in-scriptconfig/104920/5 "2025-04-09T19:59:03Z")

</div>

I import a global common project inherited by another one, and according to some settings (features activated or not) I delete unusefull code.py files and run a project rescan.
