# Gateway Timer not Triggering the Session Handler

**URL:** <https://forum.inductiveautomation.com/t/gateway-timer-not-triggering-the-session-handler/107864>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 26, 2025, 10:47pm UTC](https://forum.inductiveautomation.com/t/gateway-timer-not-triggering-the-session-handler/107864 "2025-06-26T22:47:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aisha\_Shiddat](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@Aisha\_Shiddat](https://forum.inductiveautomation.com/u/Aisha_Shiddat)\
**Post date:** [June 26, 2025, 10:47pm UTC](https://forum.inductiveautomation.com/t/gateway-timer-not-triggering-the-session-handler/107864/1 "2025-06-26T22:47:53Z")

</div>

Hello, I have a project where I am using a Gateway Timer script to trigger a session handler, that triggers a view handler that calls some custom methods. However, I'm checking my logs on the gateway and I'm not seeing the session handler sending the params to the view anymore.

Setting the session\_id in the startup:

 ![Session Startup](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/a/5adae45e9184baeadf325467426d0c917ea67c0d.png)

**Gateway Script:**

```python
# Timer Script - every 2 minutes per project (MF1, MF2, etc.)
# Created by AMS2 - Updated with active session check and writeAsync

logger = system.util.getLogger("ShiftTimer")

try:
    hmi_ip = '10.147.10.120'

    sessions = system.perspective.getSessionInfo()
    session_id = None

    for s in sessions:
        logger.info("Session found: ID {}, IP {}".format(s["id"], s["clientAddress"]))
        if s["clientAddress"] == hmi_ip:
            session_id = s["id"]
            break # Stop at first match

    if session_id is None:
        logger.warn("No active session found from IP: {}".format(hmi_ip))
    else:
        # Read tags only if session is valid
        machine = system.tag.readBlocking(["[OMA]Pipe/MF1/job_data/MachineID"])[0].value
        machine_name = system.tag.readBlocking(["[OMA]Pipe/MF1/job_data/MachineDescription"])[0].value

        # Query shift data
        ds = system.db.runNamedQuery("MF1_Dashboard", "shift/GetShiftByMachine", {"machine_id": machine})
        pyDS = system.dataset.toPyDataSet(ds)

        current_start_time_dt = pyDS[0]["start_time"] if pyDS.getRowCount() > 0 else None
        current_end_time_dt = pyDS[0]["end_time"] if pyDS.getRowCount() > 0 else None
        current_shift = pyDS[0]["shift"] if pyDS.getRowCount() > 0 else None

        old_start_time_dt = pyDS[1]["start_time"] if pyDS.getRowCount() > 1 else None
        previous_end_time_dt = pyDS[1]["end_time"] if pyDS.getRowCount() > 1 else None
        previous_shift = pyDS[1]["shift"] if pyDS.getRowCount() > 1 else None

        # Async write
        system.tag.writeAsync([
            "[OMA]Pipe/MF1/Shift_Info/StartTime",
            "[OMA]Pipe/MF1/Shift_Info/EndTime",
            "[OMA]Pipe/MF1/Shift_Info/Shift",
            "[OMA]Pipe/MF1/Shift_Info/old_start_time_dt",
            "[OMA]Pipe/MF1/Shift_Info/old_end_time_dt",
            "[OMA]Pipe/MF1/Shift_Info/last_shift_processed"
        ], [
            current_start_time_dt,
            current_end_time_dt,
            current_shift,
            old_start_time_dt,
            previous_end_time_dt,
            previous_shift
        ])

        # Send to session
        system.perspective.sendMessage(
            project="MF1_Dashboard",
            messageType="reset_tags",
            scope="session",
            sessionId=session_id,
            payload={
                "machine": machine,
                "machine_name": machine_name,
                "old_start_time_dt": old_start_time_dt,
                "trigger_ip": hmi_ip
            }
        )
        logger.info("Message sent to session {} for machine {}".format(session_id, machine_name))

except Exception as e:
    logger.error("Timer script failed: {}".format(e))

```

**Session Handler:**

```python
def handleMessage(session, payload):

    #Session Message Handler for "reset_tags"
    logger = system.util.getLogger("Shift Timer")
    
    machine = payload["machine"]
    machine_name = payload["machine_name"]
    old_start_time_dt = payload["old_start_time_dt"]
    trigger_ip = payload.get("trigger_ip", "unknown")
    

    logger.info("Reset tags message received for {} from IP {}".format(machine_name, trigger_ip))
    
    # Forward payload to view
    system.perspective.sendMessage(
        messageType="reset_tags",
        scope="view",
        payload={
            "machine": machine,
            "machine_name": machine_name,
            "old_start_time_dt": old_start_time_dt,
            "trigger_ip": trigger_ip
        }
    )
    
    logger.info("Forwarded reset_tags message to view for {}".format(machine_name))

```

**View:**

```python
def onMessageReceived(self, payload):
	system.util.getLogger("ResetTagsHandler").info("Handler triggered with:{}".format(payload))	
		
	machine = payload["machine"]
	machine_name = payload["machine_name"]
	old_start_time_dt = payload["old_start_time_dt"]
	trigger_ip = payload.get("trigger_ip", "unknown")
	
	logger = system.util.getLogger("Root Component Reset Tags Handler")
	logger.info("Reset requested from IP: {}".format(trigger_ip))
	
	#calling reset method
	self.getChild("Header").reset_tags(machine, machine_name, old_start_time_dt, trigger_ip)
	

```

---

<div class="post-metadata">

**Author:** ![Aisha\_Shiddat](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@Aisha\_Shiddat](https://forum.inductiveautomation.com/u/Aisha_Shiddat)\
**Post date:** [June 26, 2025, 11:16pm UTC](https://forum.inductiveautomation.com/t/gateway-timer-not-triggering-the-session-handler/107864/2 "2025-06-26T23:16:05Z")

</div>

I used system.util.sendMessage() instead of system.perspective.sendMessage(). That seemed to fix my issue.
