Remote web trigger not working reliably

I’m using a remote web trigger with a very simple one step macro. That said, I’ve noticed that it’s not working reliably and often failing to trigger. I have checked the KM logs and it doesn’t even register an event during these times. What’s the best way to troubleshoot this as I currently cannot rely on this macro.

Thanks :grinning:

Check this thread for some tips -- unreliability is usually because your Mac can't maintain a "long poll" connection to the server.

One way round this problem is to use a cloud service and a "watched folder" trigger instead -- create a file in a "TriggerFolder" and have a single "watcher" macro that spots that new file, fires off the appropriate macro (based on file name or contents), then deletes the file.

Since im doing this locally between two computers on the same network, I have no need for this connection to be public. Is there a different local option using keyboard maestro?

Easy mode is to turn on KM's internal web sever (see https://wiki.keyboardmaestro.com/trigger/Web_Server) and give your macro the "Public Web" trigger that way you don't need to authenticate.

You can then call the macro with an URL via a web browser, Shortcut, curl command, etc:

https://192.168.0.2:4491/action.html?macro=5123DD72-CCB7-49A8-8835-C77D839EAE3C

(changing IP and macro UUID to suit, obvs).

Or you can go to the web page and pick from a list of Public macros, or log in with the username and password you've set in KM's "Web server" preferences, to see the Protected ones.

If you want more protection than the Public macros offer but without the hassle of logging in, you could set up "passwordless" ssh (randomly chosen instructions, there's loads of others on the web) to your target machine and call by shell script -- watch the quotes, though:

ssh 192.168.0.2 'osascript -e "tell application \"Keyboard Maestro Engine\" to do script \"5123DD72-CCB7-49A8-8835-C77D839EAE3C\""'

You can also use the new CLI tool over ssh:

ssh 192.168.0.2 '/Applications/Keyboard\ Maestro.app/Contents/MacOS/keyboardmaestro "5123DD72-CCB7-49A8-8835-C77D839EAE3C"'

...which you can make shorter by setting up an alias to the CLI utility as per the Wiki page.

And there's still the option of using a "watched folder" trigger and dropping in a file over file sharing or writing it with touch over ssh, etc.

So plenty of options for you to investigate -- and I'm sure there's some I've missed!

1 Like

Genius my friend! Works like a charm and hopefully will prove much more reliable. Can’t thank you enough… :grinning: