Login Problem on WordPress for Android

I tried to login to my WordPress blog using WordPress for Andoroid, but I received the following error:

I tried to fix this issue for a long time, but it took a long time to find the solution for it. There was no problem with logging in to the wordpress.com blogs, and I could even logging into my alternative blog installed on my Bluehost web server without any problem. There are a number of causes for it, but I could make it work by installing the correct version of xml and xmlrpc module that runs my WordPress engine.

Finding the Root Cause

The following listing is the application log from WordPress for Android:

01 - WordPress.onCreate
02 - App comes from background
03 - ConnectionChangeReceiver.setEnabled true
04 - Connection status changed, isConnected=true
...
13 - No documented SNI support on Android <4.2, trying with reflection
14 - Established TLSv1.2 connection with www.cheonghyun.com using TLS_RSA_WITH_AES_128_CBC_SHA
15 - No HTTP error document document from the server
16 - system.listMethods failed on: https://www.cheonghyun.com/xmlrpc.php - exception: HTTP status code: 500 was returned. Internal Server Error
17 - StackTrace: org.xmlrpc.android.XMLRPCException: HTTP status code: 500 was returned. Internal Server Error
	at org.xmlrpc.android.XMLRPCClient$Caller.callXMLRPC(XMLRPCClient.java:547)
	at org.xmlrpc.android.XMLRPCClient$Caller.access$000(XMLRPCClient.java:430)
	at org.xmlrpc.android.XMLRPCClient.call(XMLRPCClient.java:231)
	at org.xmlrpc.android.XMLRPCClient.call(XMLRPCClient.java:226)
	at org.xmlrpc.android.XMLRPCUtils.doSystemListMethodsXMLRPC(XMLRPCUtils.java:96)
	at org.xmlrpc.android.XMLRPCUtils.checkXMLRPCEndpointValidity(XMLRPCUtils.java:203)
	at org.xmlrpc.android.XMLRPCUtils.verifyXmlrpcUrl(XMLRPCUtils.java:291)
	at org.xmlrpc.android.XMLRPCUtils.verifyOrDiscoverXmlRpcUrl(XMLRPCUtils.java:250)
	at org.wordpress.android.ui.accounts.helpers.FetchBlogListWPOrg$FetchBlogListTask.doInBackground(FetchBlogListWPOrg.java:55)
	at org.wordpress.android.ui.accounts.helpers.FetchBlogListWPOrg$FetchBlogListTask.doInBackground(FetchBlogListWPOrg.java:35)
	at android.os.AsyncTask$2.call(AsyncTask.java:287)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
	at java.util.concurrent.FutureTask.run(FutureTask.java:137)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
	at java.lang.Thread.run(Thread.java:856)
...
26 - The XML-RPC endpoint was not found by using our 'smart' cleaning approach. Time to start the Endpoint discovery process
27 - The app will call the RSD discovery process on the following URLs: [https://www.cheonghyun.com]
28 - Downloading the HTML content at the following URL: https://www.cheonghyun.com
29 - RSD endpoint found at the following address: https://www.cheonghyun.com/xmlrpc.php?rsd
30 - Downloading the RSD document...
31 - Extracting the XML-RPC Endpoint address from the RSD document
32 - Found the XML-RPC endpoint in the HTML document!!!
33 - Trying system.listMethods on the following URL: https://www.cheonghyun.com/xmlrpc.php
34 - No documented SNI support on Android <4.2, trying with reflection
35 - Established TLSv1.2 connection with www.cheonghyun.com using TLS_RSA_WITH_AES_128_CBC_SHA
36 - No HTTP error document document from the server
37 - system.listMethods failed on: https://www.cheonghyun.com/xmlrpc.php - exception: HTTP status code: 500 was returned. Internal Server Error
38 - StackTrace: org.xmlrpc.android.XMLRPCException: HTTP status code: 500 was returned. Internal Server Error
	at org.xmlrpc.android.XMLRPCClient$Caller.callXMLRPC(XMLRPCClient.java:547)
	at org.xmlrpc.android.XMLRPCClient$Caller.access$000(XMLRPCClient.java:430)
	at org.xmlrpc.android.XMLRPCClient.call(XMLRPCClient.java:231)
	at org.xmlrpc.android.XMLRPCClient.call(XMLRPCClient.java:226)
	at org.xmlrpc.android.XMLRPCUtils.doSystemListMethodsXMLRPC(XMLRPCUtils.java:96)
	at org.xmlrpc.android.XMLRPCUtils.checkXMLRPCEndpointValidity(XMLRPCUtils.java:203)
	at org.xmlrpc.android.XMLRPCUtils.discoverSelfHostedXmlrpcUrl(XMLRPCUtils.java:393)
	at org.xmlrpc.android.XMLRPCUtils.verifyOrDiscoverXmlRpcUrl(XMLRPCUtils.java:257)
	at org.wordpress.android.ui.accounts.helpers.FetchBlogListWPOrg$FetchBlogListTask.doInBackground(FetchBlogListWPOrg.java:55)
	at org.wordpress.android.ui.accounts.helpers.FetchBlogListWPOrg$FetchBlogListTask.doInBackground(FetchBlogListWPOrg.java:35)
	at android.os.AsyncTask$2.call(AsyncTask.java:287)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
	at java.util.concurrent.FutureTask.run(FutureTask.java:137)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
	at java.lang.Thread.run(Thread.java:856)
...

The application log tells that the engine causes an internal server error (500) while loading xmlrpc.php. To find out the detail, I looked into the error.log from Apache Engine. We can acquire error.log from /var/log/apache2/error.log on Ubuntu.

[Sun Oct 16 23:29:00.403764 2016] [:error] [pid 2200] [client CLIENT_IP:PORT] PHP Fatal error:  Call to undefined function xml_parser_create() in /var/www/html_main/wp-includes/class-IXR.php on line 264
[Sun Oct 16 23:29:00.403882 2016] [:error] [pid 2200] [client CLIENT_IP:PORT] PHP Stack trace:
[Sun Oct 16 23:29:00.403896 2016] [:error] [pid 2200] [client CLIENT_IP:PORT] PHP   1. {main}() /var/www/html_main/xmlrpc.php:0
[Sun Oct 16 23:29:00.403913 2016] [:error] [pid 2200] [client CLIENT_IP:PORT] PHP   2. wp_xmlrpc_server->serve_request() /var/www/xmlrpc.php:84
[Sun Oct 16 23:29:00.403922 2016] [:error] [pid 2200] [client CLIENT_IP:PORT] PHP   3. IXR_Server->IXR_Server() /var/www/wp-includes/class-wp-xmlrpc-server.php:197
[Sun Oct 16 23:29:00.403930 2016] [:error] [pid 2200] [client CLIENT_IP:PORT] PHP   4. IXR_Server->__construct() /var/www/wp-includes/class-IXR.php:440
[Sun Oct 16 23:29:00.403938 2016] [:error] [pid 2200] [client CLIENT_IP:PORT] PHP   5. IXR_Server->serve() /var/www/wp-includes/class-IXR.php:432
[Sun Oct 16 23:29:00.403945 2016] [:error] [pid 2200] [client CLIENT_IP:PORT] PHP   6. IXR_Message->parse() /var/www/wp-includes/class-IXR.php:464

According to the stack trace of error.log, the engine causes an error on processing messages and related functions.

Solution

Install the correct version of xml and xmlrpc Apache2 Module

As I stated in the beginning, I solved the login issue by installing the correct version of xml and xmlrpc module. The command line is as follows:

sudo apt-get install php5.6-xml
sudo apt-get install php5.6-xmlrpc
sudo service apache2 restart

The installation commands above depends on the php version and .htaccess configuration you are using. You can find out the current php version by creating a simple php file on your web server with the following script. Please note that the php version you installed on Apache engine and the version that you are currently using can be different.

<?php echo phpversion(); ?>

If the php version is 5.6, you can use the installation command above to solve it. (As mentioned above, you can use php -v to find out the php version from the web server engine, but the php version you are actually using can be different by .htaccess configuration or others. Therefore, checking version using php file may be more accurate than checking the php engine version.)

Reinstalling xml, xmlrpc

Some websites stated that they solved the login issue by reinstalling xml and xmlrpc modules [1, 2]. You can check the installed modules by using “php -m”.

[PHP Modules]
calendar
Core
ctype
date
...
tokenizer
wddx
xdebug
xml
xmlreader
xmlrpc
xmlwriter
zlib

If there is no xml or xmlrpc module in the list, install the module using the following command:

sudo apt-get install php-xml
sudo apt-get install php-xmlrpc

If the problem persists, reinstall the module using the following command:

sudo apt-get purge php-xml
sudo apt-get purge php-xmlrpc

.htaccess Accesss Right and PHP Version

The problem could be the access right of xmlrpc.php [3]. If this was the cause, your server would return 403 Forbidden error, rather than I mentioned above. Please modify .htaccess as follows:

<Files xmlrpc.php>
    Order allow,deny
    Allow from all
</Files>

Sometimes the problem could be the php version; you can modify the php version you wish to use by creating .htaccess file as follows (php 5.6):

# Use PHP5.6 as default
AddHandler application/x-httpd-php56 .php

References

[1] Alexander, “Fixing Errors «Jetpack: site_inaccessible,» zakharovlx.com, 08-Apr-2016. [Online]. Available: https://zakharovlx.com/category/dev/wordpress/.
[2] http://tecfused.com/, “PHP Fatal error: Uncaught Error: Call to undefined function xml_parser_create(),” tecfused.com, 08-Sep-2016. [Online]. Available: http://www.tecfused.com/2016/09/php-fatal-error-uncaught-error-call-undefined-function-xml_parser_create/.
[3] JigmeDatse, “[Resolved] The Jetpack server was unable to communicate with your site [HTTP 500],” WordPress.org, 22-Sep-2016. [Online]. Available: https://wordpress.org/support/topic/the-jetpack-server-was-unable-to-communicate-with-your-site-http-500/.

PortFast, BPDU Guard, BPDU Filtering, and UplinkFast

BPDU (Bridge Protocol Data Unit): A specialized frame to transfer the spanning tree information in 801.d STP (Spanning Tree Protocol).
RSTP (IEEE 802.w, Rapid Spanning Tree Protocol): A standard protocol revised from STP (Spanning Tree Protocol).

RSTP and STP Port States

Operational State STP State (802.1d) RSTP State (802.1w) Forwards Data Frames?
Enabled Blocking Discarding No
Enabled Listening Discarding No
Enabled Learning Learning No
Enabled Forwarding Forwarding Yes
Disabled Disabled Discarding No

PortFast

PortFast is Cisco’s technology to speed up convergence for access ports when they become active. PortFast mode supports only nontrunking access ports which do not transmit or receive BPDUs for preventing loops occured in a network. The following shows how to enable portfast on Cisco switch:

Switch> enable
Switch# configure terminal
Switch (config)# interface fastEthernet 0/1
Switch (config-if)# spanning-tree portfast

BPDU Guard

Portfast BPDU guard prevents loops by moving a nontrunking port into an errdisable state when a BPDU is received on that port. By enabling BPDU guard, spanning tree shuts down Portfast-enabled interfaces instead of putting them into the spanning tree blocking state.

BPDU Filtering

BPDU filtering allows to avoid transmitting BPDUs on Portfast-enabled ports that are connected to end system. By enabling Portfast on the switch, spanning tree places ports in the forwarding state immediately, instead of going through the listening, learning, and forwarding states.

UplinkFast

Uplinkfast provides fast convergence using uplink groups in the network access layer after a spanning tree topology change. An uplink group is a set of ports (per VLAN), only one of which is forwarding at any given time. Specifically, an uplink group consists of the root port (which is forwarding) and a set of blocked ports (not including self-looped ports). The uplink group provides an alternate path in case the currently forwarding link fails.

References

Cisco Systems, Inc. “Configuring Spanning Tree PortFast, BPDU Guard, BPDU Filter, UplinkFast, BackboneFast, and Loop Guard.” In Catalyst 4500 Series, Catalyst 2948G, Catalyst 2948G-GE-TX, and Catalyst 2980G Switches Software Configuration Guide, 8.1-8.20, 2007. http://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst4000/8-2glx/configuration/guide/stp_enha.html.