Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Error with remote control

More
4 years 9 months ago #208618 by davebostockgmail
I am having an issue with the Remote control API returning a session key via PHP, I have seen this asked before but not found an answer ...

I upgraded to Version 3.25.1+201124 this morning in the hopes that it would resolve the issue but with no luck.

I have tested using a simple script from the manual ...

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

// without composer this line can be used
// require_once 'path/to/your/rpcclient/jsonRPCClient.php';
// with composer support just add the autoloader
require_once '../application/libraries/jsonRPCClient.php';

define( 'LS_BASEURL', 'https://serverURL/index.php/'); // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'user' );
define( 'LS_PASSWORD', 'password' );


// the survey to process
$iSurveyID = surveyid;

// instantiate a new client
$myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'admin/remotecontrol' );

// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );

// receive surveys list current user can read
$groups = $myJSONRPCClient->list_surveys( $sessionKey );
print_r($groups, null );

// release the session key
$myJSONRPCClient->release_session_key( $sessionKey );
?>

But I keep getting the same error.


Fatal error: Uncaught Exception: Incorrect response id: (request id: 1) in /var/www/html/application/libraries/jsonRPCClient.php:192 Stack trace: #0 /var/www/html/survey/test.php(22): jsonRPCClient->__call('get_session_key', Array) #1 {main} thrown in /var/www/html/application/libraries/jsonRPCClient.php on line 192

I have checked and I have remote control turned on in the settings and I have rebooted the servers all to no avail.

Does anyone know of a solution to this?

Thanks
The topic has been locked.
More
4 years 9 months ago #208619 by DenisChenu

define( 'LS_BASEURL', 'https://serverURL/index.php/'); // adjust this one to your actual LimeSurvey URL
// instantiate a new client
$myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'admin/remotecontrol' );


No … it can be false and totally something else (and can explain the issue you have). Check the real url in the admin page, and use it directly.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
4 years 9 months ago #208621 by tpartner
Replied by tpartner on topic Error with remote control
I use this:

Code:
// Instantiate a new RPC client
    $myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/index.php/admin/remotecontrol' );

- forums.limesurvey.org/forum/can-i-do-thi...-access-token#204528

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
4 years 9 months ago #208622 by DenisChenu

tpartner wrote: I use this:

Code:
// Instantiate a new RPC client
    $myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/index.php/admin/remotecontrol' );

- forums.limesurvey.org/forum/can-i-do-thi...-access-token#204528

Yes, but it can be false… with url as GET

Can be

/index.php?r=admin/remotecontrol
/?r=admin/remotecontrol
/index.php/admin/remotecontrol
/admin/remotecontrol

:)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
4 years 9 months ago #208623 by davebostockgmail
I have tried both yours and Denis' changes and still get the same error.

The PHP version we are running is 7.3 ... would that make any difference?
The topic has been locked.
More
4 years 9 months ago #208624 by DenisChenu
Did you look at your config ?
You don't have to try : you must be sure :)

www.limesurvey.org/manual/Global_settings#Interfaces

It's activated ?

If you activate Publish API : you see the page ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
4 years 9 months ago #208626 by davebostockgmail
it is all on as far as I can see.
The topic has been locked.
More
4 years 9 months ago #208627 by davebostockgmail
And when i go to the page I see the list of the commands for the API
The topic has been locked.
More
4 years 8 months ago #208679 by davebostockgmail
I have managed to work around the issue I have with PHP and SQL. I wanted to add data to the participant table with a known TOKEN id.

Over the holidays we are going to rebuild the servers with the latest version and hopefully this will fix the issues we are having.

Thanks for your thoughts on this

Dave
The topic has been locked.
More
4 years 8 months ago #208681 by DenisChenu
Else : did server log (where limesurvey are) show something ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
4 years 8 months ago #208683 by davebostockgmail
Not that I could see Denis.

I think that this along with the error I have with comfort update are indicative of an error in our site installation ... so a clean build should hopefully resolve any issues we have.

Our IT team recently went on an exercise where they updated all the firewall rules both external and internal and this is when the issues started appearing so I am assuming that this may be the root cause.

A clean installation on new VM's would allow me to test without any rules being in place and then I can work through the rules they apply to see if any of those impacted the survey VM.

If I do find out anything then I will report back here in case others have a similar issue.
The topic has been locked.
More
4 years 8 months ago #208689 by DenisChenu

davebostockgmail wrote: Our IT team recently went on an exercise where they updated all the firewall rules both external and internal and this is when the issues started appearing so I am assuming that this may be the root cause.

OK :)

Surely you can't get limesurvey sezrver url from the other server.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
4 years 8 months ago #208690 by davebostockgmail
I can see the URL's but from other documentation I have seen there needs to be specific ports open for RCP to work ... As it was working before and not now this is where I will start the investigation.
The topic has been locked.
More
3 years 10 months ago #220650 by abbasi1
Replied by abbasi1 on topic Error with remote control
I am getting the exact same error when I try to copy a survey from a source survey. I am successfully activating the survey using the same session key.
The topic has been locked.
More
3 years 10 months ago #220651 by davebostockgmail
Here is how I got around the API issue .. maybe it will be the same for you?

I had an issue with remote control via PHP .. not sure if it is the same with Python.

It turns out that the JSON RPC client does not work well with self certified SSL websites .. this meant that I could see the correct page at the Remote Control admin page but the act of interacting with the API would throw an error.

This took some time figure out as I tried everything I could think of including turning off all the Firewall rules to see if it was a data routing issue and going as far as to do a full reinstall of LimeSurvey to try to fix it.... it turns out that to correct my issue I had to add the following line into the jsonRPCClient.php file found in /application/libraries

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);

inserted at the section around line 158 in that file.

Once I added in this line of code then the Remote control worked as expected.

I have no idea why it doesnt like self certified SSL but I hope this helps as it was one of the things that was extremely frustrating
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose