- Posts: 11
- Thank you received: 2
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
remotecontrol doesn't work after update to 6.3.5
- migliorati
- Topic Author
- Offline
- New Member
Less
More
1 year 8 months ago #231012
by migliorati
Replied by migliorati on topic remotecontrol doesn't work after update to 5.3
Hi Haris.
In my case the code reported by Tammo (the code normally used to access LimeSurvey) didn't work on the release 5.3 of LimeSurvey.
Looking a bit in detail the implementation of get_session_key reported on github:
github.com/cloudyr/limer/blob/master/R/get_session_key.R
I verified that the problem producing the http 500 error is that the implementation uses the field "admin" in body.json definition, and this field doesn't seem available in versione5.3 (instead it was running in the old version).
Changing the implementation of get_session_key using the field "username", instead, is working:
mm_get_session_key <- function() {
body.json = list(method = "get_session_key",
id = 1,
params = list(username = getOption('lime_username'),
password = getOption('lime_password')))
r <- POST(getOption('lime_api'),
content_type_json(),
body = jsonlite::toJSON(body.json,
auto_unbox = TRUE))
session_key <- as.character(jsonlite::fromJSON(content(r, encoding="utf-8"))$result)
session_cache$session_key <- session_key
return(session_key)
}
In my case the code reported by Tammo (the code normally used to access LimeSurvey) didn't work on the release 5.3 of LimeSurvey.
Looking a bit in detail the implementation of get_session_key reported on github:
github.com/cloudyr/limer/blob/master/R/get_session_key.R
I verified that the problem producing the http 500 error is that the implementation uses the field "admin" in body.json definition, and this field doesn't seem available in versione5.3 (instead it was running in the old version).
Changing the implementation of get_session_key using the field "username", instead, is working:
mm_get_session_key <- function() {
body.json = list(method = "get_session_key",
id = 1,
params = list(username = getOption('lime_username'),
password = getOption('lime_password')))
r <- POST(getOption('lime_api'),
content_type_json(),
body = jsonlite::toJSON(body.json,
auto_unbox = TRUE))
session_key <- as.character(jsonlite::fromJSON(content(r, encoding="utf-8"))$result)
session_cache$session_key <- session_key
return(session_key)
}
The following user(s) said Thank You: r0bis
Please Log in to join the conversation.
- Haris.Pap
- Offline
- New Member
Less
More
- Posts: 17
- Thank you received: 0
1 year 8 months ago #231027
by Haris.Pap
Replied by Haris.Pap on topic remotecontrol doesn't work after update to 5.3
Thanks a lot for the info, which actually seems to be specific to the limer implementation.
Looking at the API implementation in application\helpers\remotecontrol\remotecontrol_handle.php, the get_session_key function uses only a username parameter.
The answer is that remotecontrol works correctly with LimeSurvey 5.3.
The solution to my problem was that the requests were not being resolved by the server. An entry in the hosts file solved the issue.
Looking at the API implementation in application\helpers\remotecontrol\remotecontrol_handle.php, the get_session_key function uses only a username parameter.
The answer is that remotecontrol works correctly with LimeSurvey 5.3.
The solution to my problem was that the requests were not being resolved by the server. An entry in the hosts file solved the issue.
Please Log in to join the conversation.
- migliorati
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 2
1 year 8 months ago #231029
by migliorati
Replied by migliorati on topic remotecontrol doesn't work after update to 5.3
Sure, but something has changed in Limesurvey, too, because the same code was working in past releases.
I don't know if such a change was documented, but it would be important.
I don't know if such a change was documented, but it would be important.
Please Log in to join the conversation.
- Jane
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 16
- Thank you received: 14
1 year 3 months ago - 1 year 3 months ago #239195
by Jane
Replied by Jane on topic remotecontrol doesn't work after update to 5.3
Did you also update your PHP from version 7 to version 8? If so, try loading a fixed limer:
devtools::install_github("Jan-E/limer", force = TRUE)
See my fork of limer at github.com/Jan-E/limer/ for an explanation. See especially the commit + comment:
[url] github.com/Jan-E/limer/commit/bc807c61fb...376d814e80f126fc796c [/url]
Please report back if this fixes your problems before I create a pull request for limer.
devtools::install_github("Jan-E/limer", force = TRUE)
See my fork of limer at github.com/Jan-E/limer/ for an explanation. See especially the commit + comment:
[url] github.com/Jan-E/limer/commit/bc807c61fb...376d814e80f126fc796c [/url]
Please report back if this fixes your problems before I create a pull request for limer.
Last edit: 1 year 3 months ago by Jane. Reason: Link to the commit
The following user(s) said Thank You: r0bis
Please Log in to join the conversation.
- Jane
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 16
- Thank you received: 14
1 year 3 months ago #239196
by Jane
Replied by Jane on topic remotecontrol doesn't work after update to 5.3
Nothing has changed in Limesurvey, but PHP8 is not tolerant for non-existing keys. Probably somewhere in the remotecontrol code PHP8 misses a $username and exits with an error, while PHP7 skips over the error and returns a session_ley to LimeR. Debugging is hard, because the YII framework does not seem to log why the RC2 fails.Sure, but something has changed in Limesurvey, too, because the same code was working in past releases.
I don't know if such a change was documented, but it would be important.
Please Log in to join the conversation.
- Jane
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 16
- Thank you received: 14
1 year 3 months ago #239202
by Jane
Replied by Jane on topic remotecontrol doesn't work after update to PHP 8.1
Created PR in the limer repo:
github.com/cloudyr/limer/pull/62
github.com/cloudyr/limer/pull/62
The following user(s) said Thank You: DenisChenu, r0bis
Please Log in to join the conversation.
- r0bis
- Offline
- Senior Member
Less
More
- Posts: 60
- Thank you received: 7
1 year 2 weeks ago - 1 year 2 weeks ago #242014
by r0bis
r0berts
Replied by r0bis on topic remotecontrol doesn't work after update to PHP 8.1
Thanks a lot for finding the bug and fixing it. There seems to be no response to that on the main limer branch. My server currently runs on PHP 7.3 and all was fine, but in the future, I will need to use github_install() from devtools to install limer from Jan-E's branch.
Code:
devtools::install_github("Jan-E/limer", force = TRUE)
r0berts
Last edit: 1 year 2 weeks ago by r0bis. Reason: added new information
Please Log in to join the conversation.
- Jane
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 16
- Thank you received: 14
1 year 1 week ago - 1 year 1 week ago #242339
by Jane
Replied by Jane on topic remotecontrol doesn't work after update to PHP 8.1
See
Please merge PR get_session_key.R: fix PHP 8.1 major flaw #62
now. The PR was finally merged. LimeR is compatible with PHP 7 and PHP 8!
Last edit: 1 year 1 week ago by Jane.
The following user(s) said Thank You: r0bis
Please Log in to join the conversation.
- iceclimber81
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 3
5 months 3 days ago #252408
by iceclimber81
Replied by iceclimber81 on topic remotecontrol doesn't work after update to 5.3
Hi Jane,
I know I'm joining this conversation late, but I'm still hoping for some help or illumination:
I use the R package limer to retrieve survey data via remotecontrol from Limesurvey Cloud. It worked well until early October (must have been LS version 6.2.11 then). Now, running on LS 6.3.6, I get the same error message as reported above when trying to get a session key with get_session_key(): "Error: Argument 'txt' must be a JSON string, URL or file."
I have already tried using your fixed version of limer devtools::install_github("Jan-E/limer", force = TRUE) but this hasn't changed the outcome. I don't know which version of PHP is used by Limesurvey Cloud.
Are others experiencing similar issues? Any thoughts on solutions?
Thanks!
Clemens
I know I'm joining this conversation late, but I'm still hoping for some help or illumination:
I use the R package limer to retrieve survey data via remotecontrol from Limesurvey Cloud. It worked well until early October (must have been LS version 6.2.11 then). Now, running on LS 6.3.6, I get the same error message as reported above when trying to get a session key with get_session_key(): "Error: Argument 'txt' must be a JSON string, URL or file."
I have already tried using your fixed version of limer devtools::install_github("Jan-E/limer", force = TRUE) but this hasn't changed the outcome. I don't know which version of PHP is used by Limesurvey Cloud.
Are others experiencing similar issues? Any thoughts on solutions?
Thanks!
Clemens
Please Log in to join the conversation.
- r0bis
- Offline
- Senior Member
Less
More
- Posts: 60
- Thank you received: 7
5 months 3 days ago - 5 months 3 days ago #252412
by r0bis
r0berts
Replied by r0bis on topic remotecontrol doesn't work after update to 5.3
This is really quite bad, I get the same error and the only change I made was used comfort update. Now LS version is
LimeSurvey Community Edition Version 6.3.6+231120
and my PHP has been 7.4 for a good few months and until this update was working well.
I played around with function from migliorati and came to conclusion that a lot of things work. But it seems that the response coming back from limesurvey might not be JSON? for example you do the usual limer options setup and then:
body.json = list(method = "get_session_key",
id = 1,
params = list(username = getOption('lime_username'),
password = getOption('lime_password')))
now you have the json rpc request (I think); then you give that request to httr::POST
POST(getOption('lime_api'),
content_type_json(),
body = jsonlite::toJSON(body.json,
auto_unbox = TRUE))
you get a response similar to :Response [ lime.server.yours/index.php/admin/remotecontrol ]
Date: 2023-11-20 19:21
Status: 500
Content-Type: text/html; charset=UTF-8
Size: 20.8 kB
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
" www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns=" www.w3.org/1999/xhtml " xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>ArgumentCountError</title>
<style type="text/css">
/*<![CDATA[*/say instead of printing you save it to an object RRR, then I am sure in RRR$cookies[7] you have your session key
LimeSurvey Community Edition Version 6.3.6+231120
and my PHP has been 7.4 for a good few months and until this update was working well.
I played around with function from migliorati and came to conclusion that a lot of things work. But it seems that the response coming back from limesurvey might not be JSON? for example you do the usual limer options setup and then:
body.json = list(method = "get_session_key",
id = 1,
params = list(username = getOption('lime_username'),
password = getOption('lime_password')))
now you have the json rpc request (I think); then you give that request to httr::POST
POST(getOption('lime_api'),
content_type_json(),
body = jsonlite::toJSON(body.json,
auto_unbox = TRUE))
you get a response similar to :Response [ lime.server.yours/index.php/admin/remotecontrol ]
Date: 2023-11-20 19:21
Status: 500
Content-Type: text/html; charset=UTF-8
Size: 20.8 kB
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
" www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns=" www.w3.org/1999/xhtml " xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>ArgumentCountError</title>
<style type="text/css">
/*<![CDATA[*/say instead of printing you save it to an object RRR, then I am sure in RRR$cookies[7] you have your session key
r0berts
Last edit: 5 months 3 days ago by r0bis.
Please Log in to join the conversation.
- iceclimber81
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 3
5 months 3 days ago - 5 months 3 days ago #252424
by iceclimber81
Replied by iceclimber81 on topic remotecontrol doesn't work after update to 5.3
Thanks for looking into this, r0bis.
I just experimented with limer / remotecontrol on different LS versions on my server and found that it still works on LS 6.3.4, but the upgrade to LS 6.3.5 (and later) breaks it.
When checking the changelog , I found this issue mentioned for 6.3.4 --> 6.3.5: Fixed issue #19214: JSON RPC response content type should be application/json (#3610) --> see issue described here: bugs.limesurvey.org/view.php?id=19214
If I understand correctly, starting from 6.3.5, the JSON RPC response content type is application/json, while before it was text/javascript. This might break the limer get_session_key() function.
UPDATE: Getting an error message:
When trying to call the remotecontrol API with the limer approach on LS 6.3.5 and later:
the response shows an error message:
Unfortunately, I'm not familiar enough with JSON to figure out how to modify the request so it is valid.
I just experimented with limer / remotecontrol on different LS versions on my server and found that it still works on LS 6.3.4, but the upgrade to LS 6.3.5 (and later) breaks it.
When checking the changelog , I found this issue mentioned for 6.3.4 --> 6.3.5: Fixed issue #19214: JSON RPC response content type should be application/json (#3610) --> see issue described here: bugs.limesurvey.org/view.php?id=19214
If I understand correctly, starting from 6.3.5, the JSON RPC response content type is application/json, while before it was text/javascript. This might break the limer get_session_key() function.
UPDATE: Getting an error message:
When trying to call the remotecontrol API with the limer approach on LS 6.3.5 and later:
Code:
body.json = list(method = "get_session_key", id = 1, params = list(username = getOption('lime_username'), password = getOption('lime_password'))) r <- POST(getOption('lime_api'), content_type_json(), body = jsonlite::toJSON(body.json, auto_unbox = TRUE)) xml <- content(r, encoding="utf-8") rvest::html_text(xml)
the response shows an error message:
Code:
500: Internal Server Error call_user_func_array(): Argument #1 ($callback) must be a valid callback, second array member is not a valid method
Unfortunately, I'm not familiar enough with JSON to figure out how to modify the request so it is valid.
Last edit: 5 months 3 days ago by iceclimber81.
Please Log in to join the conversation.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13624
- Thank you received: 2490
5 months 2 days ago #252433
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic remotecontrol doesn't work after update to 5.3
Please : report the issue,
community.limesurvey.org/bug-tracker/
Since this breaks a pre-existing system, it's a problem that needs to be solved!
community.limesurvey.org/bug-tracker/
Since this breaks a pre-existing system, it's a problem that needs to be solved!
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: iceclimber81
Please Log in to join the conversation.