Debugging network requests in the Moodle App: Difference between revisions
- Moodle App Overview
- Moodle App Development Guide
- Moodle App Plugins Development Guide
- Moodle App Remote Themes
- Moodle App Customisation
- Setting up your development environment
- Using the Moodle App in a browser
- Moodle App Translation
- Moodle App FAQ
- Moodle App Development Process
- Moodle App Release Notes
Upgrade from previous versions:
- See all Moodle App pages
- See pages for Moodle App Ionic 5 (current)
- See pages for Moodle App Ionic 3 (legacy)
- See pages Moodle App Ionic 1 (legacy)
- See pages for Moodle App Phonegap (legacy)
For user documentation see Moodle Mobile
Juan Leyva (talk | contribs) |
Dev Docs Bot (talk | contribs) (Update migration status and path) |
||
(27 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
{{Moodle | {{Template:Migrated|newDocId=/general/app/development/network-debug}} | ||
{{Moodle App (Ionic 5)}} | |||
== Introduction == | == Introduction == | ||
This guide will help you find and report problems with the Moodle App on your site. | |||
It is especially useful for the following problems: | |||
* Unable to log in on your site. | |||
* | |||
* When you receive one of the following error messages in the app: | * When you receive one of the following error messages in the app: | ||
** Can not find data record in database table external_functions | ** "Can not find data record in database table external_functions". | ||
** Invalid response value detected | ** "Invalid response value detected". | ||
** Cannot get course contents | ** "Cannot get course contents". | ||
== Enabling debugging on your Moodle site == | == Enabling debugging on your Moodle site == | ||
# Go to Debugging in the Site administration. | |||
# For "Debug messages" select 'DEVELOPER'. | |||
# Tick "Display debug messages". | |||
# Click the 'Save changes' button. | |||
Remember to disable debugging again once you have finished debugging your problem. | |||
== Enabling debugging on the Moodle App == | |||
# Go to More | # Go to the More tab. | ||
# | # Go to Settings > General. | ||
# Enable "Display debug messages". | |||
# Enable | |||
== | Remember to disable debugging again once you have finished debugging your problem. | ||
== First attempts == | |||
At this point, you may not need to go further on this guide. | |||
Log out and log in again into your site and try to reproduce the error. Hopefully, with Moodle and app debugging enabled you will see an explanatory message of what is happening. | |||
If you are unable to find a solution, contact a [https://moodle.com/partners/ Moodle Partner] or post in the [https://moodle.org/mod/forum/view.php?id=7798 Moodle for mobile forum] on moodle.org for non-guaranteed community support. | |||
== Setting up the debugging tool == | |||
=== Using a Browser === | |||
In your [[Using the Moodle App in a browser|Chromium-based browser]], you can access your site using the hosted versions of the app in [https://master.apps.moodledemo.net master.apps.moodledemo.net] (the latest stable version) and [https://integration.apps.moodledemo.net integration.apps.moodledemo.net]. | |||
== | Once you're using your site, you can open the [https://developer.chrome.com/docs/devtools/network/ Network panel] of the developer tools and inspect requests. If you're only interested in web service requests, [https://developer.chrome.com/docs/devtools/network/#filter you can filter] writing <code>.php</code> in the filter input. | ||
=== Using a mobile device or emulator === | |||
If you are using a native device, keep in mind that some requests are not executed through the webview and you won't be able to see them in the network inspector of your developer tools. Instead, you'll have to use native tools the debug the requests. | |||
For example, in Android you can use [https://developer.android.com/studio/profile/network-profiler the Network Profiler]. | |||
=== General strategy === | |||
Here's how to debug web service errors: | |||
# Ignore requests that don’t start with <code>token.php</code> or <code>server.php</code>. | |||
# Once you have selected a request you want to inspect, open the "Response" tab and check if you see an error. | |||
# If you don't understand how to fix the error, you can search in [[:en:Moodle Mobile FAQ|Moodle Mobile FAQ]] to check if there is a known solution. | |||
# If you are unable to find a solution, contact a [https://moodle.com/partners/ Moodle Partner] or post in the [https://moodle.org/mod/forum/view.php?id=7798 Moodle for mobile forum] on moodle.org for non-guaranteed community support. | |||
== Troubleshooting == | |||
=== How to log into a site configured to use browser or embedded authentication === | |||
You can execute the following in the JavaScript console: | |||
<syntaxhighlight lang="javascript"> | |||
window.handleOpenURL("moodlemobile://URL?token=WSTOKEN"); | |||
</syntaxhighlight> | |||
You can also launch a normal authentication process (allowing the authentication popup) and capture the redirect to <code>moodlemobile://...</code> created by the <code>admin/tool/mobile/launch.php</code> script and then execute the following in the console: | |||
<syntaxhighlight lang="javascript"> | |||
window.handleOpenURL("moodlemobile://token=ABCxNGUxMD........="); | |||
</syntaxhighlight> |
Latest revision as of 13:01, 14 July 2022
Important:
This content of this page has been updated and migrated to the new Moodle Developer Resources. The information contained on the page should no longer be seen up-to-date. Why not view this page on the new site and help us to migrate more content to the new site! |
Introduction
This guide will help you find and report problems with the Moodle App on your site.
It is especially useful for the following problems:
- Unable to log in on your site.
- When you receive one of the following error messages in the app:
- "Can not find data record in database table external_functions".
- "Invalid response value detected".
- "Cannot get course contents".
Enabling debugging on your Moodle site
- Go to Debugging in the Site administration.
- For "Debug messages" select 'DEVELOPER'.
- Tick "Display debug messages".
- Click the 'Save changes' button.
Remember to disable debugging again once you have finished debugging your problem.
Enabling debugging on the Moodle App
- Go to the More tab.
- Go to Settings > General.
- Enable "Display debug messages".
Remember to disable debugging again once you have finished debugging your problem.
First attempts
At this point, you may not need to go further on this guide.
Log out and log in again into your site and try to reproduce the error. Hopefully, with Moodle and app debugging enabled you will see an explanatory message of what is happening.
If you are unable to find a solution, contact a Moodle Partner or post in the Moodle for mobile forum on moodle.org for non-guaranteed community support.
Setting up the debugging tool
Using a Browser
In your Chromium-based browser, you can access your site using the hosted versions of the app in master.apps.moodledemo.net (the latest stable version) and integration.apps.moodledemo.net.
Once you're using your site, you can open the Network panel of the developer tools and inspect requests. If you're only interested in web service requests, you can filter writing .php
in the filter input.
Using a mobile device or emulator
If you are using a native device, keep in mind that some requests are not executed through the webview and you won't be able to see them in the network inspector of your developer tools. Instead, you'll have to use native tools the debug the requests.
For example, in Android you can use the Network Profiler.
General strategy
Here's how to debug web service errors:
- Ignore requests that don’t start with
token.php
orserver.php
. - Once you have selected a request you want to inspect, open the "Response" tab and check if you see an error.
- If you don't understand how to fix the error, you can search in Moodle Mobile FAQ to check if there is a known solution.
- If you are unable to find a solution, contact a Moodle Partner or post in the Moodle for mobile forum on moodle.org for non-guaranteed community support.
Troubleshooting
How to log into a site configured to use browser or embedded authentication
You can execute the following in the JavaScript console:
window.handleOpenURL("moodlemobile://URL?token=WSTOKEN");
You can also launch a normal authentication process (allowing the authentication popup) and capture the redirect to moodlemobile://...
created by the admin/tool/mobile/launch.php
script and then execute the following in the console:
window.handleOpenURL("moodlemobile://token=ABCxNGUxMD........=");