tl;dr Node-RED is great for quick setup of polling, Directory Assistance document path separators are platform-specific and adding a correct new Directory Assistance makes any new directories immediately available.

I've made no secret of my passion for Node-RED. I'm also someone who will find out how something works rather than just go for the nuclear option. So when I needed to set up a new directory in Directory Assistance on a customer server, I wanted to make sure I used the most efficient method for getting it working. Why restart a server if you don't have to? But when you're trying various options, you need to know which one fixed it and why. Typically when (not if!) I get something wrong, I try a variety of things. On more than one occasion in the past for this kind of "trial and error" approach, there has been more than one change between something not working and it working. Identifying which one worked and why is always a challenge, especially if there's a potential that it could just be timing of a cache reloading.

So this was checking when authentication worked. Historically my approach would have been try various things including leaving some time, manually log into the app and see if it worked. But this time I took a new approach. I know how to create an authenticated request to Domino and check whether it works or not - the code's openly available on my Node-RED demo from Engage, and I think I got that JavaScript from OpenNTF's login area. To get something that polled every 30 seconds and told me quickly and easily when it logged in successfully took three nodes and a few minutes:

The first is an inject node, set to run 0.1 seconds after Node-RED starts and repeat every 30 seconds.

The second is an http request node, set to go to "/names.nsf/$icon" on my dev server, with basic authentication using the username and password of a user I set up in the new directory, and set to return a UTF-8 string.

The third is a function node, checking for whether msg.payload.includes('DOCTYPE'). If it does, the server's returned the authentication page, so login failed. If it doesn't, the directory is working. I use node.warn() to write an appropriate message to Node-RED's debug panel.

Deploy the flow, and I can see it's logging the info and polling every 30 seconds. Of course, I tested it first with a username and password that worked and one that wouldn't, so I know that as soon as the new directory starts working, I'll get the message I expect.

Yes, I could now have used LotusScript, or I could have used an XAgent, or something else. But Node-RED allowed me to do it quickly, easily - and enjoyably.

Next step was setting up the entry in Directory Assistance. Will it just pick up after a certain amount of time, or do I need to do anything?

I waited, started troubleshooting and found out my first error. The show xdir console command dumps out Directory Assistance's config. For my new directory, the DomainName column was blank and the ClientProtocol column had "UNKNOWN". On working directories, the DomainName column had a value and the ClientProtocol column had "NOTES". After some searching, a technote gave me the root of the problem. I had copied the filepath for the new directory from the web, so I wouldn't get a typo. So I had forward slashes instead of back slashes. That would probably have been fine on Linux (so Domino on Docker). But for Windows, the path separator needs to filepath on the Directory Assistance document needs backslashes. Issuing the show xdir console command confirmed it was working. On the same wiki page I found that command, I also found confirmation that if any changes were made, on Domino 7 and 8 it can be updated immediately by issuing the show xdir reload. So that's what I did.

But this is where regular polling proved extremely useful. After issuing that command and checking Node-RED, I found my polling had already been successfully connecting for some time. The debug panel gave me the time it had successfully connected. So I went back through the Notes log to see what I had been doing on the server at the time and try to link the two. Between the failed show xdir and the successful one was a message "Directory Assistance is reloading internal tables due to change in change in Directory Assistance database." The time was about 30 seconds after saving the Directory Assistance document for the directory, and it corresponded to the start of the successful polling.

The investigation allowed me to successfully set up Directory Assistance on the production server and ensure it enabled with minimum effort and minimum impact to the customer.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.