Having Problems With Using Remote Trigger Reliably

I've been having issues getting remote triggers to work reliably. Sometimes they work, and times I need to delete the trigger and re-create it to get them to work. Today nothing would make my remote YouTube download work remotely, so I tried turning off the Keyboard Maestro's web server checkbox and turning it on again...and it magically started working, but only once. My goal is to "fire" some actions on my work iMac from remote locations on iOS devices.

When I run the trigger URL in my browser, I sometimes see a 1 returned in the browser, sometimes a 2, and sometimes a 0. Is this useful information for debugging this?

EDIT I just rebooted the computer and my Mac promptly began the command I'd asked it to execute. Is there a "best practice" for making Remote Trigger work better in more situations?

Hi @ppayne, I myself use Siri shortcuts for this either with an SSH script (on the same network).

or via iCloud Drive when I'm on the road.

Both work reliably for me.

So is that using the remote trigger, accessing a specific URL to cause the macro to begin on the main computer? The issue is that sometimes the scripts don't get the message to begin the macro, even when I run the URL in a browser on that very computer. Sometimes restarting makes it work, other times it works well, but sometimes the computer ignores the trigger URLs.

Also maybe you should hide that script URL?

1 Like

I have the same problems. Sometimes working, sometimes not. I want to put the Remote Trigger in an URL in slides.com to switch scenes in OBS.

The Keyboard Maestro web server has nothing to do with Remote triggers. Any connection was either coincidental, or related to network issue.

The number returned is the number of registered trigger instances that the trigger server knows about.

So 0 would indicate no registered triggers. 1 would be normal, and 2 would indicate either multiple Macs or multiple macros with the same trigger.

The Remote trigger works by the Keyboard Maestro Engine keeping a long-poll connection to the trigger server.

The most common failure mode is the intervening network forgetting about the connection route, despite the keep-alive settings. This results in the trigger working for a period of time after it is first activated, and then failing until it is reactivated, or until Keyboard Maestro’s active ping (which happens after 30+ minutes) notices the dropped connection and reestablishes the connection (and then the whole process repeats). Thus disabling and reenabling the macro would resolve the issue for a period of time, after which it would fail again.

Other than that, I don't know of any reliability issues. There is a bunch a debugging that can be enabled with commands like:

defaults write com.stairways.keyboardmaestro.engine Debug "RemoteTriggerMonitor RemoteTrigger"

and then restarting the Keyboard Maestro Engine and monitoring the Engine.log file.

As of last week, various macros triggered by Remote Web Trigger suffer a delay between 0 seconds and 8 minutes. This, of course, does not demonstrate that a problem with the KM server exists, but it causes me to wonder whether others are experiencing similar problems.

It's hard to even ponder what the issue might be without more information.

The trigger works by connecting to the server and waiting for a message.

Triggering it works by connecting to the server, which then immediately sends the message to any appropriate connected servers. There isn't any buffering. If Keyboard Maestro is not connected and listening, then the message would not be sent.

So I have no idea where the “8 minutes” delay would come from.

I would look at whatever is sending the trigger, and how your macro is behaving. Maybe there are network issues connecting to the trigger server to initiate the trigger?

1 Like

I'm starting to have problems with remote trigger also. I have a remote trigger that fires first thing in the morning and it stopped working. I can get it to start working by stopping and restarting the KBM engine. I have debug enabled as suggested but I can't see why it would be failing overnight.

defaults write com.stairways.keyboardmaestro.engine Debug "RemoteTriggerMonitor RemoteTrigger"

I'm not sure what to look for in the engine log but I see it doing this sequence periodically overnight in the log:

2023-05-11 19:15:31 RemoteTriggerMonitor didCloseWithCode 1001 reason Stream end encountered wasClean 0
2023-05-11 19:15:31 RemoteTriggerMonitor reopen
2023-05-11 19:15:31 RemoteTriggerMonitor open
2023-05-11 19:15:31 RemoteTriggerMonitor actualOpen
2023-05-11 19:15:31 RemoteTriggerMonitor did open
2023-05-11 19:15:31 RemoteTriggerMonitor send IAM:1:10.2:5HFBX305EY2BGCWDNG:OK
2023-05-11 19:15:31 RemoteTriggerMonitor send REG:321F320C-0884[**sequence of comma separated trigger codes**] 
2023-05-11 19:15:31 RemoteTriggerMonitor got message: GOOD

I tried sending a remote trigger multiple times but nothing shows up in the log. If I stop the engine, I see it unregister all of the remote triggers. Then I start the engine and I see it register all the triggers. Sending a remote trigger then works.

I started seeing remote trigger failures after moving from my iMac to a new Mac Mini M2. I have set to not put the hard disks to sleep and allow it to wake for network access. Is there something else I should look for?

1 Like