Failed WordPress to Moodle test connection
-
After successfully managing to activate the Edwiser plugin in my WordPress installation (as described in my previous topic), I proceeded to set up the connection between WordPress and Moodle. Edwiser Plugin is 4.0.0. WordPress is 6.7.2. Moodle is Moodle 4.5.3+ (Build: 20250328)
Both platforms WordPress and Moodle are installed on the same Linux system, using apache2 web server with two configured VirtualHosts:
https://lms.wordpress.localhttps://lms.moodle.local
In Moodle, I completed the necessary setup and generated an access token:
2f73e220ba27271267ecf26a48156eefUsing this token along with the Moodle URL
https://lms.moodle.local, I attempted to verify the connection through the Edwiser Bridge plugin in WordPress. However, when I click “Test Connection”, the plugin returns an error in red:“Test Connection failed. To check more information about the issue click [here].”
Upon clicking the [here] link, I receive a detailed error message that says:
Status :
Connection Failed
Url :
https://lms.moodle.local/webservice/rest/server.php?wstoken=2f73e220ba27271267ecf26a48156eef&wsfunction=auth_edwiserbridge_test_connection&moodlewsrestformat=jsonResponse :
A valid URL was not provided.
Click Troubleshoot button to get more detailsIf I now use this given link in my web browser manually I am getting this response from moodle
{"exception":"core\\exception\\invalid_parameter_exception","errorcode":"invalidparameter","message":"Invalid parameter value detected"}Clicking Troubleshoot returns me
Diagnostics Completed
(Not ok)Does API return a valid JSON response?Get More Details
(ok)Are there any spaces before/after the token?
(ok)Is the moodle site webservice accessible?
(ok)Are permalink settings correctly configured and rest api accessible?
(ok)Can moodle read data from WordPress(GET endpoint)?
(ok)Can moodle write data to WordPress(POST endpoint)?
Does API return a valid JSON response?Get More Details
Are there any spaces before/after the token?
Is the moodle site webservice accessible?
Are permalink settings correctly configured and rest api accessible?
Can moodle read data from WordPress(GET endpoint)?
Can moodle write data to WordPress(POST endpoint)?
What did I wrong?
Thank you
Armin
-
Hi Armin,
Congratulations on successfully activating the Edwiser plugin in your WordPress installation! We understand you are now facing an issue while trying to connect it with your Moodle site.
The error message “Invalid parameter value detected” from Moodle indicates that there might be an issue with one of the parameters being sent in the connection test request. Let’s try to troubleshoot this step by step.
Based on the information you have shared, we tested using Postman and encountered the following error when trying to reach
lms.moodle.local:Error: getaddrinfo ENOTFOUND lms.moodle.local
Additionally, we attempted to access the following URLs in a browser, but they appear to be unreachable:
To help us understand the situation better, could you please verify if your website addresses (
lms.wordpress.localandlms.moodle.local) are correctly configured on your local machine to point to the IP address of your server? Thegetaddrinfo ENOTFOUNDerror typically indicates that your system cannot find a DNS entry for the hostname.Please check your local hosts file:
- On Linux/macOS:
/etc/hosts - On Windows:
C:\Windows\System32\drivers\etc\hosts
Ensure that there are entries in this file mapping
lms.wordpress.localandlms.moodle.localto the correct IP address of your server (usually127.0.0.1if accessed locally on the same machine).Could you also confirm that your Apache web server is running and properly configured to listen on the correct IP addresses and ports for these hostnames, as defined in your VirtualHost configurations?
Please let us know if these websites are intended to be live and accessible from your current network setup.
Sincerely,
Edwiser Support Team
Hello,
The two specified URLs are only accessible within my local home network.
The Ubuntu server, where both applications are installed and running under Apache2, has the local IP address 192.168.30.40. On my home DNS server, I configured the hostnames lms.wordpress.local and lms.moodle.local to resolve to this IP address. Therefore, it is of course expected that these URLs are not reachable from the internet by you.
The Apache server is functioning correctly, as I can access the WordPress admin interface via lms.wordpress.local and the Moodle admin interface via lms.moodle.local without any issues.
Additionally, when accessing the local server via the following URL:
https://lms.moodle.local/webservice/rest/server.php?wstoken=2f73e220ba27271267ecf26a48156eef&wsfunction=auth_edwiserbridge_test_connection&moodlewsrestformat=json
the browser returns the following JSON-formatted response coming from Moodle web server interface:{"exception":"core\\exception\\invalid_parameter_exception","errorcode":"invalidparameter","message":"Invalid parameter value detected"}This response clearly indicates that both Apache2 and the Moodle installation are functioning correctly and the web server interface is active. If Apache2 were misconfigured or Moodle were not properly set up, the browser would not return a structured error message—instead, it would result in a timeout or connection error.
If I call the same command with an invalid token, the response is
{"exception":"core\\exception\\moodle_exception","errorcode":"invalidtoken","message":"Invalid token - token not found"}To demonstrate that my Moodle instance is functioning properly and also my token ist correct, I verified the same Moodle instance and webservice interface by accessing the following URL:
I am getting this response
{"sitename":"Test","username":"admin","firstname":"Armin","lastname":"xxxx","fullname":"Armin xxxx","lang":"en","userid":2,"siteurl":"https:\/\/lms.moodle.local","userpictureurl":"https:\/\/lms.moodle.local\/pluginfile.php\/5\/user\/icon\/degrade\/f1?rev=175","functions":[{"name":"core_user_create_users","version":"2024100703.04"},{"name":"core_user_delete_users","version":"2024100703.04"},{"name":"core_user_get_users_by_field","version":"2024100703.04"},{"name":"core_user_update_users","version":"2024100703.04"},{"name":"core_course_get_courses","version":"2024100703.04"},{"name":"core_course_get_courses_by_field","version":"2024100703.04"},{"name":"core_course_get_categories","version":"2024100703.04"},{"name":"enrol_manual_enrol_users","version":"2024100700"},{"name":"enrol_manual_unenrol_users","version":"2024100700"},{"name":"core_enrol_get_users_courses","version":"2024100703.04"},{"name":"core_cohort_add_cohort_members","version":"2024100703.04"},{"name":"core_cohort_create_cohorts","version":"2024100703.04"},{"name":"core_role_assign_roles","version":"2024100703.04"},{"name":"core_role_unassign_roles","version":"2024100703.04"},{"name":"core_cohort_delete_cohort_members","version":"2024100703.04"},{"name":"core_cohort_get_cohorts","version":"2024100703.04"},{"name":"core_webservice_get_site_info","version":"2024100703.04"},{"name":"auth_edwiserbridge_test_connection","version":"2025040200"},{"name":"auth_edwiserbridge_get_site_data","version":"2025040200"},{"name":"auth_edwiserbridge_get_course_progress","version":"2025040200"},{"name":"auth_edwiserbridge_get_edwiser_plugins_info","version":"2025040200"},{"name":"auth_edwiserbridge_get_course_enrollment_method","version":"2025040200"},{"name":"auth_edwiserbridge_update_course_enrollment_method","version":"2025040200"},{"name":"auth_edwiserbridge_get_mandatory_settings","version":"2025040200"},{"name":"auth_edwiserbridge_enable_plugin_settings","version":"2025040200"},{"name":"auth_edwiserbridge_validate_token","version":"2025040200"},{"name":"auth_edwiserbridge_verify_sso_token","version":"2025040200"},{"name":"auth_edwiserbridge_get_users","version":"2025040200"},{"name":"auth_edwiserbridge_get_courses","version":"2025040200"},{"name":"auth_edwiserbridge_manage_cohort_enrollment","version":"2025040200"},{"name":"auth_edwiserbridge_delete_cohort","version":"2025040200"},{"name":"auth_edwiserbridge_manage_user_cohort_enrollment","version":"2025040200"}],"downloadfiles":1,"uploadfiles":1,"release":"4.5.3+ (Build: 20250328)","version":"2024100703.04","mobilecssurl":"","advancedfeatures":[{"name":"usecomments","value":1},{"name":"usetags","value":1},{"name":"enablenotes","value":1},{"name":"messaging","value":1},{"name":"enableblogs","value":1},{"name":"enablecompletion","value":1},{"name":"enablebadges","value":1},{"name":"messagingallusers","value":0},{"name":"enablecustomreports","value":1},{"name":"enableglobalsearch","value":0},{"name":"mnet_dispatcher_mode","value":0},{"name":"enablecompetencies","value":1}],"usercanmanageownfiles":true,"userquota":0,"usermaxuploadfilesize":-1,"userhomepage":0,"userprivateaccesskey":"f13747c321e5e6990fb8685e2e0e7bfd","siteid":1,"sitecalendartype":"gregorian","usercalendartype":"gregorian","userissiteadmin":true,"theme":"degrade","limitconcurrentlogins":0,"policyagreed":0}As you can see, basic web service access is functioning correctly.
The only difference lies in the
wsfunctionparameter. Moreover, since thecore_webservice_get_site_infocall returns a JSON response listing all supported web service functions, this confirms that the functionauth_edwiserbridge_test_connectionshould indeed be available and supported.Is there any configuration in Moodle that I might have overlooked which could prevent receiving a valid response from the web service interface?
P.S.: I would also like to inform you that, once my private testing with Edwiser Bridge at home is successfully completed, the company I work for intends to proceed with the purchase of an official Edwiser Bridge Pro Lifetime license in Q3/2025.
Thanks
ArminHello Armin,
Thank you for the detailed information. Our development team has reviewed the troubleshooting steps we’ve taken so far and has a few more suggestions to help us understand why the connection test is failing.
- It appears that Moodle is not returning a JSON response for some reason.
- Possible causes for this issue may include:
- An incorrect SSL installation
- WordPress blocking the request
- The site being hosted in a local environment
- We have observed that in certain local setups, the
wp_safe_remote_postorwp_safe_remote_getfunctions may not function correctly, as they might incorrectly flag the request as a potential SSRF (Server-Side Request Forgery) attempt.
Next Steps:
- Please navigate to the
edwiser-bridge/admin/class-eb-settings-ajax-initiater.phpfile and locate thecheck_valid_json_responsemethod. - Within this method, you will find two API requests:
- On Line 177:phpCopy Code
$internal_response = wp_safe_remote_get($url2, array('timeout' => '60')); - On Line 188:phpCopy Code
$response = $connection_helper->get_raw_response($url, $token);
- On Line 177:phpCopy Code
- We recommend adding error logs to capture the responses from these variables to identify where the failure occurs during troubleshooting.
- Additionally, please share the error logs with us for further analysis.
Code to Ping Your Localhost Server:
We are also providing a code snippet to help you diagnose the situation with your localhost server:
phpCopy Code
<?php $host = 'wordpress.com'; // WordPress site URL // $host = 'moodle.com'; // Moodle site URL $port = 80; $timeout = 50; $connection = @fsockopen($host, $port, $errno, $errstr, $timeout); if ($connection) { echo 'Website is up!'; fclose($connection); } else { echo 'Website is down: ' . $errstr . "\n"; } ?>- To run this file, please use the following command:CodeCopy Code
php -f your_file_name.php - First, try using WordPress with the port while commenting out the Moodle URL. Then, try Moodle with the port while commenting out the WordPress URL.
Thanks,
Edwiser Support Team
Thank you for your proposal.
There is one thing I need to understand and this is why I am repeating what I wrote yesterday
- I am opening my Chrome web browser (this has nothing to do with WordPress and works independently)
- I am entering the following URL line to the address bar (to simulate access to moodle service) https://lms.moodle.local/webservice/rest/server.php?wstoken=2f73e220ba27271267ecf26a48156eef&wsfunction=auth_edwiserbridge_test_connection&moodlewsrestformat=json
- This line accesses the web server in Moodle directly and should address ediser plugin in moodle and this access does not use any WordPress code since all runs in my Chrome browser
- Then I get back the following textual response in the Chrome browser
{"exception":"core\\exception\\invalid_parameter_exception","errorcode":"invalidparameter","message":"Invalid parameter value detected"}
But now you are writing that I have to change source code in WordPress in order to debug Moodle web services. Should we not rather see why the simple combination of Chrome and with Moodle does not work?
I want to follow your idea of changing wordpress edwiser plugin code. I extended the following line in
edwiser-bridge/admin/class-eb-settings-ajax-initiater.php
public function connection_test_initiater() {
error_log('connection_test_initiater() called');
// verifying generated nonce we created earlier.
if ( ! isset( $_POST['_wpnonce_field'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce_field'] ) ), 'check_sync_action' ) ) {
die( 'Busted!' );and I also edited the following line
public function check_valid_json_response() {
error_log('check_valid_json_response() called');
// verifying generated nonce we created earlier.
if ( ! isset( $_POST['_wpnonce_field'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce_field'] ) ), 'check_sync_action' ) ) {
wp_send_json_error();
}
// start working on request.
$url = isset( $_POST['url'] ) ? sanitize_text_field( wp_unslash( $_POST['url'] ) ) : '';Then I clicked on your “Test Connection” button in Edwiser plugin afterwards and I was looking to my ./wp-content/debug.log file
It says[10-Apr-2025 14:40:36 UTC] connection_test_initiater() calledThere is no indication that
check_valid_json_response()was called at all.I continued my tests and inserted one more error_log()
public function connection_test_initiater() {
error_log('connection_test_initiater() called');
// verifying generated nonce we created earlier.
if ( ! isset( $_POST['_wpnonce_field'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce_field'] ) ), 'check_sync_action' ) ) {
die( 'Busted!' );
}
// start working on request.
$url = isset( $_POST['url'] ) ? sanitize_text_field( wp_unslash( $_POST['url'] ) ) : '';
$token = isset( $_POST['token'] ) ? sanitize_text_field( wp_unslash( $_POST['token'] ) ) : '';
$connection_helper = new Eb_Connection_Helper( $this->plugin_name, $this->version );
$response = $connection_helper->connection_test_helper( $url, $token );
echo wp_json_encode( $response );
error_log(wp_json_encode( $response));
die();
}Then I watched my debug file again. It says
[10-Apr-2025 14:56:22 UTC] connection_test_initiater() called
[10-Apr-2025 14:56:22 UTC] {"success":0,"response_message":"
\n
\n Test Connection failed, To check more information about issue click here <\/span>.\n <\/div>\n\n
\n \t
\n\t
\n\t An issue is detected. <\/h4>\n\t
\n\t \t
Status : <\/b><\/div>\n\t \t
Connection Failed <\/div>\n\t <\/div>\n\t
\n\t \t
Url : <\/b><\/div>\n\t \t
https:\/\/lms.moodle.local\/webservice\/rest\/server.php?wstoken=2f73e220ba27271267ecf26a48156eef&wsfunction=auth_edwiserbridge_test_connection&moodlewsrestformat=json<\/div>\n\t <\/div>\n\t
\n\t \t
Response : <\/b><\/div>\n\t \t
A valid URL was not provided.<\/div>\n\t <\/div>\n\t\t\t\t\t\t\t\t\t
\n\t \t
Click Troubleshoot <\/strong> button to get more details.<\/div>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t <\/div>\n\n\t
\n\t\t\t\t\t\t\t\t\t<\/span> \n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t
\n <\/div>\n <\/div>"}Hello Armin,
Kindly refer to the details provided below:
There might be an issue with your server setup, and unfortunately, we can’t troubleshoot it without accessing the system directly.
The request being made is a POST request. Since browsers use GET requests when you directly paste a URL, the connection won’t work properly. Please try testing it using a tool like Postman.
You indicated that you incorporated logs within the check_valid_json_response() function; however, it appears that you did not subsequently click the “Troubleshoot” button. This function is only activated upon clicking that button. Additionally, please make certain that you have included logs at the specified lines prior to conducting your tests.
Line 177:
$internal_response = wp_safe_remote_get($url2, array(‘timeout’ => ’60’));
Line 188:
$response = $connection_helper->get_raw_response($url, $token);
You can use the following code to check if the Moodle or WordPress site is accessible via basic server connection:
To test connectivity:
Create a .php file and paste this code inside it.
Save this file inside the root directory of your WordPress site (where wp-config.php is located) and test the Moodle URL by replacing the $host.
Then save the file inside the root directory of your Moodle site (where wp-config.php is located )and test the WordPress URL by replacing the $host.
Also, share all the output you are getting via screenshot or video.
Thanks,
Edwiser Support TeamYou are writing to test a code, but I can’t find it in your post. It might be forgotten, or?
Thanks
ArminNevertheless to the missing code in your post, I went back to add troubleshooting code in line 177 and line 188 and click “Troubleshoot” this time. (have not recognized that I have to click it also)
Here is the result:
[12-Apr-2025 03:45:48 UTC] $internal_response:
[12-Apr-2025 03:45:48 UTC] {"headers":{},"body":"{\"namespace\":\"edwiser-bridge\",\"routes\":{\"\\/edwiser-bridge\":{\"namespace\":\"edwiser-bridge\",\"methods\":[\"GET\"],\"endpoints\":[{\"methods\":[\"GET\"],\"args\":{\"namespace\":{\"default\":\"edwiser-bridge\",\"required\":false},\"context\":{\"default\":\"view\",\"required\":false}}}],\"_links\":{\"self\":[{\"href\":\"https:\\/\\/lms.wordpress.local\\/wp-json\\/edwiser-bridge\"}]}},\"\\/edwiser-bridge\\/wisdmlabs\":{\"namespace\":\"edwiser-bridge\",\"methods\":[\"POST\",\"PUT\",\"PATCH\"],\"endpoints\":[{\"methods\":[\"POST\",\"PUT\",\"PATCH\"],\"args\":[]}],\"_links\":{\"self\":[{\"href\":\"https:\\/\\/lms.wordpress.local\\/wp-json\\/edwiser-bridge\\/wisdmlabs\"}]}}},\"_links\":{\"up\":[{\"href\":\"https:\\/\\/lms.wordpress.local\\/wp-json\\/\"}]}}","response":{"code":200,"message":"OK"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}}
[12-Apr-2025 03:45:48 UTC] $response:
[12-Apr-2025 03:45:48 UTC] {"errors":{"http_request_failed":["A valid URL was not provided."]},"error_data":[]}If I decode the body of the “$internal_response” it comes to
{
"namespace": "edwiser-bridge",
"routes": {
"/edwiser-bridge": {
"namespace": "edwiser-bridge",
"methods": [
"GET"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"namespace": {
"default": "edwiser-bridge",
"required": false
},
"context": {
"default": "view",
"required": false
}
}
}
],
"_links": {
"self": [
{
"href": "https://lms.wordpress.local/wp-json/edwiser-bridge"
}
]
}
},
"/edwiser-bridge/wisdmlabs": {
"namespace": "edwiser-bridge",
"methods": [
"POST",
"PUT",
"PATCH"
],
"endpoints": [
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": []
}
],
"_links": {
"self": [
{
"href": "https://lms.wordpress.local/wp-json/edwiser-bridge/wisdmlabs"
}
]
}
}
},
"_links": {
"up": [
{
"href": "https://lms.wordpress.local/wp-json/"
}
]
}
}Does it help?
Hello Armin,
We have reviewed the shared results and this seems to be a configuration issue or potentially related to the server setup. If possible, please create a video walkthrough or share screenshots of the entire process, as it will help us better understand the issue and also allow us to replicate it in our testing environment.
Thank you for your understanding!
Edwiser Support Team
Assuming I set up a virtual machine on a Windows system with a fresh Ubuntu 24.xx installation, and walked you through the roughly 20 Linux commands required to install WordPress and Moodle and Edwiser plugins — and assuming I could reproduce the exact same issue in that environment — my question is: would you be able to run such a VM on your end to verify it?
If not, there’s no point in me investing time in preparing this setup.
Please advise.
And I’m not sure if you’ve noticed, but Moodle 5.0 was released two days ago.
Since older versions will be reaching end-of-support, I’ll be moving forward with the installation of Moodle 5.0.Regards
ArminHello again,
I’ve prepared a Virtual Machine (runs via Oracle VM VirtualBox) with a fully configured Ubuntu 24.04 system. It includes:
- Apache2 web server
- WordPress 6.8
- Moodle 5.0
- Edwiser 4.0.0 plugins installed for both WordPress and Moodle
However, even in this setup, the Edwiser Wizard is still unable to establish communication between the two applications running on the same linux machine.
This VM can be used to test the setup on any Windows PC worldwide. I can provide a download link for the VM image along with the user credentials for Ubuntu, WordPress, and Moodle.
Would it be okay if I send this information to [email protected]?
Best regards,
ArminArmin,
Thank you for your email and for providing the details about your setup. We appreciate your efforts in preparing the Virtual Machine with the configured Ubuntu system and the necessary applications.
I want to confirm that we have received your information and are currently working on this case. Our development team is looking into the communication issue between the Edwiser Wizard, WordPress, and Moodle. We will update you as soon as we have more information.
Thank you for your patience and understanding.
Edwiser Support Team
- On Linux/macOS:
The topic ‘Failed WordPress to Moodle test connection’ is closed to new replies.