Error Connecting to the Server

Error Connecting to the Server

by Sya Rahim -
Number of replies: 11

Hi,

I have a few users from my site that received the "Error Connecting to the Server" when they tried to the access through the Moodle Mobile App. I have asked them to reinstall/update the App on their Android phones, but the error still occur. I have checked and found that their Android version too have been updated. I have not  restore the courses to Moodle Cloud. Can anyone help?

Attachment WhatsApp Image 2019-01-30 at 11.32.33.jpeg
Average of ratings: -
In reply to Sya Rahim

Re: Error Connecting to the Server

by Isabel Renedo -
Picture of Moodle HQ Picture of Particularly helpful Moodlers

Hi Sya,


We used to debug these kind of errors ourselves, but due to GDPR we can no longer do it, that's why we created this guide: https://docs.moodle.org/dev/Moodle_Mobile_debugging_WS_requests#Enabling_debugging_on_your_Moodle_site, particularly to: 3 Enabling debugging on your Moodle site and 4 Enabling debugging on the mobile app.

With this guide you should be able to get an error message providing more information. To reproduce the problem, we recommend that a test account is created and is enrolled in the exact same courses as the user experiencing the issues is. 

Regards,

Isabel

In reply to Isabel Renedo

Re: Error Connecting to the Server

by Mykola Kostiuchenko -

Hi Isabel,

I have the same error in Moodle client when I try click "Next" in lessons.

I tried enable debugging by your instruction. But I don't see more information about error.

Can you help me resolve problem?


Regard,

Mykola

In reply to Mykola Kostiuchenko

Re: Error Connecting to the Server

by Denise Pernigotti -

I have the same problem with lesson, any help?

thanks,

Denise

In reply to Denise Pernigotti

Re: Error Connecting to the Server

by Isabel Renedo -
Picture of Moodle HQ Picture of Particularly helpful Moodlers
Hi Denise,

Please check https://docs.moodle.org/dev/Moodle_Mobile_debugging_WS_requests#Enabling_debugging_on_your_Moodle_site, particularly to: step 6 'Setting up the debugging tool' and step 7 'Debugging a web service (WS) error'.

While inspecting you should be able to see which request is failing and what information is being sent. Please check:
Preview and Response tabs to check if there is any code error, and please take a screenshot of each of these tabs
Headers tab please copy us what's failing here. If you are unsure, please copy in here everything that is in that tab. Please do NOT include your token (wstoken) as this is sensitive information about your site

Regards,
Isabel
In reply to Mykola Kostiuchenko

Re: Error Connecting to the Server

by Isabel Renedo -
Picture of Moodle HQ Picture of Particularly helpful Moodlers
Hi Mykola,

Please check https://docs.moodle.org/dev/Moodle_Mobile_debugging_WS_requests#Enabling_debugging_on_your_Moodle_site, particularly to: step 6 'Setting up the debugging tool' and step 7 'Debugging a web service (WS) error'. 

While inspecting you should be able to see which request is failing and what information is being sent. Please check:
  • Preview and Response tabs to check if there is any code error, and please take a screenshot of each of these tabs
  • Headers tab please copy us what's failing here. If you are unsure, please copy in here everything that is in that tab. Please do NOT include your token (wstoken) as this is sensitive information about your site

Regards,
Isabel
In reply to Isabel Renedo

Re: Error Connecting to the Server

by Mykola Kostiuchenko -

Hi Isabel,

I installed Moodle desktop application and I see error for lesson:

preview

Response

Text from Preview tab:

<br />
<b>Notice</b>:  Undefined property: stdClass::$attemptsremaining in <b>/var/www/moodle/mod/lesson/locallib.php</b> on line <b>3412</b><br />
{"newpageid":43,"inmediatejump":true,"nodefaultresponse":false,"feedback":"","attemptsremaining":null,"correctanswer":false,"noanswer":false,"isessayquestion":false,"maxattemptsreached":false,"response":"","studentanswer":"","userresponse":"","reviewmode":false,"ongoingscore":"","progress":null,"displaymenu":false,"messages":[],"warnings":[]}

Text from Response tab:

<br />
<b>Notice</b>:  Undefined property: stdClass::$attemptsremaining in <b>/var/www/moodle/mod/lesson/locallib.php</b> on line <b>3412</b><br />
{"newpageid":43,"inmediatejump":true,"nodefaultresponse":false,"feedback":"","attemptsremaining":null,"correctanswer":false,"noanswer":false,"isessayquestion":false,"maxattemptsreached":false,"response":"","studentanswer":"","userresponse":"","reviewmode":false,"ongoingscore":"","progress":null,"displaymenu":false,"messages":[],"warnings":[]}

Test from Headers (I've replaced sensitive information to ######):

Request URL: https://###########/moodle/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=mod_lesson_process_page
Request Method: POST
Status Code: 200 OK
Remote Address: ##########:443
Referrer Policy: no-referrer-when-downgrade
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US
Connection: keep-alive
Content-Length: 386
Content-Type: application/x-www-form-urlencoded
Cookie: MoodleSession=#########
Host: ##############
Origin: file://
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) moodledesktop/3.7.0 Chrome/69.0.3497.106 Electron/4.0.1 Safari/537.36 MoodleMobile
moodlewsrestformat: json
wsfunction: mod_lesson_process_page
lessonid: 4
pageid: 27
data[0][name]: id
data[0][value]: 192
data[1][name]: jumpto
data[1][value]: -1
data[2][name]: pageid
data[2][value]: 27
data[3][name]: sesskey
data[3][value]: #########
review: 0
moodlewssettingfilter: true
moodlewssettingfileurl: true
wsfunction: mod_lesson_process_page
wstoken: ########


Regards,

Mykola

In reply to Mykola Kostiuchenko

Re: Error Connecting to the Server

by Isabel Renedo -
Picture of Moodle HQ Picture of Particularly helpful Moodlers

Hi Mykola,

Those Notices are probably due to the fact that you have the debugging on. Please disable it on your site (Site administration >> Development >> Debugging). Probably changing 'Display debug messages' to No is enough, if not please change the 'Debug messages' to NONE: Do not show any errors or warnings.

Regards,
Isabel

In reply to Isabel Renedo

Re: Error Connecting to the Server

by Mykola Kostiuchenko -

Hi Isabel,

I have disable debugging but I still see error in Desktop App:

error

Response:

<br />
<b>Notice</b>:  Undefined property: stdClass::$attemptsremaining in <b>/var/www/moodle/mod/lesson/locallib.php</b> on line <b>3412</b><br />
{"newpageid":43,"inmediatejump":true,"nodefaultresponse":false,"feedback":"","attemptsremaining":null,"correctanswer":false,"noanswer":false,"isessayquestion":false,"maxattemptsreached":false,"response":"","studentanswer":"","userresponse":"","reviewmode":false,"ongoingscore":"","progress":null,"displaymenu":false,"messages":[],"warnings":[]}


Regards,

Mykola

In reply to Sya Rahim

Re: Error Connecting to the Server

by Johnny Tsheke -

Hi,

I'am getting the same error on  moodle desktop 3.7.2 as well as with Android  app 3.8.2 and  moodle 3.5 and

I can login login on the apps. When I clic on "Available courses":

  • I get "Error connecting to the server" if I'm using the app with an ordinary user account
  • Everything works fine when I'm using the app with an administrator account.
  • I tried with local account as well as with an LDAP account and still getting the same result.


So, how to fix that?


Thanks a lot.

In reply to Johnny Tsheke

Re: Error Connecting to the Server

by Baskar Kannaiah -

Hi,

You have create .htaccess file in your Moodle root directory. 

The below code should be there in the .htaccess file.
<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
</IfModule>

For more details, you can see my youtube video:-