Open-Live-Writer : How to solve invalid response from XmlRpc server error

Open Live Writer XML-RPC Invalid Server Response Connection Problem

When writing drafts for my blog posts, I prefer to use offline blog authoring editors. First, I used Windows Live Writer, part of Windows Essential, but after it reached the end of support in 2017, I switched to forked open-sourced version "Open Live Writer". I also installed EasyPHP on my local machine, to publish the drafts to my local WordPress site for further processing. The problem was that the "Open Live Writer" was not letting me add a blog account. It was giving me an error message about Invalid Server Response. In this article, I will show you what I tried and what fixed the issue.

The error message I received was:

Can't connect to your blog service:

Invalid Server Response - The response to the blogger.getUsersBlogs method received from the blog server was invalid:

Invalid response document returned from XmlRpc server

Please try fixing the problem and then try again.

Note: If the blog account is already added, but you cannot login to your blog, then you get "An unexpected error has occurred while attempting to log in:" error with same invalid server response.

When adding a blog account, I also tried to choose “Other services” option, instead of “WordPress”, but received the same error message.

Next I changed the “Web address of your blog:” field to only point to localhost at 127.0.0.1:

open live writer add blog account localhost

This opened a different window “Select blog type”:

open live writer add blog account select blog type

After choosing “WordPress 2.2+” from the "Select Blog Provider" dropdown menu, the “Remote posting web address for your blog:” field was filled with the following link:

http://<hostname>/<wp_path>/xmlrpc.php

I edited this link to point to the xmlrpc.php file of my local WordPress site, but again I received the same error:

open live writer add blog account invalid response document xmlrpc error

It seemed the issue was not with the setup in Open Live Writer / OLW, but was somewhere else. Here are the different ways I tried to solve the problem:

Checking XML-RPC function in WordPress

Since the Open Live Writer error message mentioned XmlRpc and the application were giving me the option to add a path to xmlrpc.php file, I first focused on XML-RPC.

XML Remote Procedure Call or XML-RPC allows you to interact remotely with your WordPress website. There are posts on the web suggesting to turn on XML-RPC in WordPress, but it turns out, this feature is turned on by default since WordPress 3.5.

To determine, if XML-RPC is enabled on WordPress, go to www.yoursite.com/xmlrpc.php which should give you the following message:

XML-RPC server accepts POST requests only.

If the XML-RPC is enabled, then running xmlrpc.php in browser will cause 405 status error (Method not allowed) and display the above message as this was GET and not POST requests.

XML-RPC functionality blocked by your hosting provider

This solution was suggested by Bruce commentator and it seems to be a common issue.

Years ago, there was a vulnerability in the xmlrpc.php WordPress core file, so some hosting providers blocked the functionality of this file. Nowadays though, the REST API is replacing the functionality of xmlrpc.php so various hosting providers are again started blocking it.

Luckily, the solution for it is pretty simple. Make a copy of xmlrpc.php file and name it something else like xmlrpc2.php. Now all that is left is to use URL that points to this duplicated file:

www.yoursite.com/xmlrpc2.php

In my case, the XML-RPC was working fine, so I kept looking.

Increasing memory limit and File Upload Limit in php.ini

Then I stumbled on some suggestions that the memory_limit or upload_max_filesize in PHP might be too low. Inside the php.ini file, I had the following settings:

upload_max_filesize = 2M
memory_limit = 128M

They looked fine to me, but I increased the upload_max_filesize to 25M just in case. After stopping / restarting Apache server, this change didn’t do anything.

Checking Open Live Writer log file

Then I discovered that the OpenLiveWriter had a log file.

On Win10, the file is located at:
%LOCALAPPDATA%\OpenLiveWriter

if you are still using Windows Live Writer, the log file should be located at:
%LOCALAPPDATA%\Windows Live Writer

When I checked the log, I noticed the following error message:

<b>Deprecated</b>:  Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in <b>Unknown</b> on line <b>0</b><br />
 <br />
<b>Warning</b>:  Cannot modify header information - headers already sent in <b>Unknown</b> on line <b>0</b><br />
 <?xml version=""1.0"" encoding=""UTF-8""?>

This seemed to indicate that while WordPress XRP-RPC was expecting XML format, it instead received the PHP deprecated warning. This warning breaks the XML and causes it to complain that the XML response was invalid. So the obvious solution was to get rid of this deprecated warning.

Removing the PHP deprecated warning

The error in Open Live Writer log file mentioned $HTTP_RAW_POST_DATA being deprecated and to set always_populate_raw_post_data to -1. In php.ini, this line was commented out:

;always_populate_raw_post_data = –1

After removing the comment and restarting the server, the Open Live Writer was able to add a blog account and publish my draft to the local WordPress site without any issue.

Note: For more information about $HTTP_RAW_POST_DATA, check this official PHP page about it.

Another way to get rid of the warning

The solution in the previous section was simple, but what if you have a notice, strict or deprecated warning and you are unsure how to fix it. The quickest way would be to make sure the PHP doesn't complain about them. We achieve this by setting error_reporting in php.ini to the values below:

error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED

Conclusion

If you are using Open Live Writer or any other blog authoring editors and get an error about Invalid Server Response using XML-RPC, it might be due to php.ini configuration. Checking the Open Live Writer log file can give us a clue, on what exactly is causing the issue. In my case, it was due to PHP "deprecated" warning. Fixing this warning solved the issue.

Tags:

3 Comments

  1. yaron
    November 30, 2017
  2. Bruce
    February 5, 2018
  3. Louis Kessler
    April 14, 2021

Write a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.