6.0.7 - Headless Client Plug-in getClient Broken?

The forum to discuss the Headless version of Servoy. Web, Java and Servlet development questions can all be posted here.

6.0.7 - Headless Client Plug-in getClient Broken?

Postby bobcusick1332964082 » Wed Sep 19, 2012 9:05 pm

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:

Code: Select all
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:

Code: Select all
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
Attachments
headless_running_but_wont_recognize_it.PNG
The code is correctly getting the GUI, but the getClient is not
headless_running_but_wont_recognize_it.PNG (14.45 KiB) Viewed 2128 times
bobcusick1332964082
 
Posts: 85
Joined: Wed Mar 28, 2012 9:48 pm

Re: 6.0.7 - Headless Client Plug-in getClient Broken?

Postby Hans Nieuwenhuis » Tue Oct 16, 2012 3:44 pm

Hi Bob,

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

Regards,
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: 6.0.7 - Headless Client Plug-in getClient Broken?

Postby rgansevles » Wed Oct 17, 2012 12:41 pm

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

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


Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1838
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: 6.0.7 - Headless Client Plug-in getClient Broken?

Postby antonio » Sun Nov 18, 2012 10:28 am

rgansevles wrote: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
Servoy Developer Version 5.2.16
Developer MAC OSX 10.8.4 Java version 1.6.0_51
Production Debian Linux Java version 1.6.0_29
antonio
 
Posts: 622
Joined: Sun Apr 02, 2006 2:14 am
Location: Australia

Re: 6.0.7 - Headless Client Plug-in getClient Broken?

Postby rgansevles » Mon Nov 19, 2012 11:30 am

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
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1838
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: 6.0.7 - Headless Client Plug-in getClient Broken?

Postby antonio » Mon Nov 19, 2012 11:40 am

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...."
Tony
Servoy Developer Version 5.2.16
Developer MAC OSX 10.8.4 Java version 1.6.0_51
Production Debian Linux Java version 1.6.0_29
antonio
 
Posts: 622
Joined: Sun Apr 02, 2006 2:14 am
Location: Australia

Re: 6.0.7 - Headless Client Plug-in getClient Broken?

Postby rgansevles » Mon Nov 19, 2012 12:47 pm

Will do.

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1838
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL


Return to Servoy Headless Client

Who is online

Users browsing this forum: No registered users and 1 guest