6.0.7 - Headless Client Plug-in getClient Broken?

Maybe someone can help me out here - I’m banging my head against a wall on this one.

I’m starting up a headless client on the server via code and executing a global method. So far, so good.

However, I then want to be able to use that spawned client for other users to do the same thing.

So, I’m using:

headlessClient = plugins.headlessclient.getClient(headlessID)

I have the UUID of the client (as I captured it after I created it) - but still the call to getClient gives me a null or invalid result.

I’ve tried a number of approaches - including this one:

var headlessClient = null;
var cnt = application.getClientCountForInfo("PDFBOT");

if(cnt == 0) {
	//not running - create it
	// Creates a headless client that will open the given solution.
	headlessClient = plugins.headlessclient.createClient("myBotSolution", "userName", "password", null);

} else {
	//running - get the ID
	var botID = null;
	var clients = plugins.maintenance.getConnectedClients();
	for (var i = 0; i < clients.length; i++) {
		if(utils.stringPatternCount(clients[i].getUserName(),"PDFBOT") > 0) {
			//found the BOT
			var botID = clients[i].getClientID();
			break
		}
	}

/*** THIS CORRECTLY RETURNS THE HEADLESS CLIENT ID OF:  "FBDAD129-4DF2-4CC4-8508-747EFC23EFC8" ***/

	if(botID) {
		// Gets an existing headless client for the given client uuid.
		headlessClient = plugins.headlessclient.getClient(botID);  // <----- HERE IS WHERE IT'S NOT WORKING
	} else {
		application.output("Your PDF generation request FAILED because we couldn't find a running bot." );
		return;
	}
}

if (headlessClient != null && headlessClient.isValid()) {
	var x = new Object();
	x.value = myRecordID;
	headlessClient.queueMethod(null, "runCronMethod", [x], globals.PDFBotCallback);

} else {
	application.output("Error - Your PDF generation request FAILED to queue");
}

Is there anything obvious I’m missing here?

Any help would be appreciated!

Bob

Hi Bob,

did you find out what the issue was ?
I have the same problem.

Regards,

The headless client plugin has manages its own client ids, these are not the same as the internal client id which is displayed on the admin page.
You can get a handle to the client using the getClientID() method

	var client = plugins.headlessclient.createClient(solutionName,username,password,solutionOpenMethodArgs);
	var clientHandle = client.getClientID();
	
	...
	
	client = plugins.headlessclient.getClient(clientHandle);

Rob

rgansevles:
The headless client plugin has manages its own client ids, these are not the same as the internal client id which is displayed on the admin page.
You can get a handle to the client using the getClientID() method

Thanks Rob, I thought I was going nuts. Could you add an entry in the docs to explain?

For a client created with plugins.headlessclient.createClient() is there any way to get the corresponding client ID that’s displayed on the admin page?

Tony,

We have to keep the internal client id hidden for security reasons, so unfortunately you cannot that client id.

Maybe application.addClientInfo() can help you here, you can set some info on the admin page that is specific to your client instance.

Rob

Thanks Rob, good suggestion.
A note in the docs would be helpful, to the effect “the client ID reported by hc.getClientID() is unrelated to the client ID displayed…”

Will do.

Rob