Page MenuHomePhabricator

"Error loading data from server: apierror-visualeditor-docserver-http-error: (curl error: 7) Couldn't connect to server."
Closed, ResolvedPublic

Description

Hello,

I apologize if I am posting this issue in the wrong place to begin with...I searched for help online without much success. I have been battling with this issue for the last few days and I think I am pretty close to getting it to work but need some help.

I have installed MediaWiki on Centos 7. It is working great. However, the Visual Editor is the one causing the issue. I have followed the setup guidelines as mentioned in https://www.mediawiki.org/wiki/Parsoid/Setup#Configuration. I can also access the api.php page from http://myserverip/api.php and I can also see the API documentation (Parsoid web service) under http://myserverip:8000

However, when I click "Edit" on the menu, it tries to load the Visual Editor but fails with the message "Error loading data from server: apierror-visualeditor-docserver-http-error: (curl error: 7) Couldn't connect to server. Would you like to retry?"

Below is my LocalSettings.php file:

# End of automatically generated settings.
# Add more configuration options below.
# This is for loading the VisualEditor
wfLoadExtension( 'VisualEditor' );

// Enable by default for everybody
$wgDefaultUserOptions['visualeditor-enable'] = 1;

// Optional: Set VisualEditor as the default for anonymous users
// otherwise they will have to switch to VE
// $wgDefaultUserOptions['visualeditor-editor'] = "visualeditor";

// Don't allow users to disable it
$wgHiddenPrefs[] = 'visualeditor-enable';

// OPTIONAL: Enable VisualEditor's experimental code features
#$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1;

$wgVirtualRestConfig['modules']['parsoid'] = array(
    // URL to the Parsoid instance
    // Use port 8142 if you use the Debian package
    'url' => 'http://localhost:8000',
    // Parsoid "domain", see below (optional)
    'domain' => 'localhost',
    // Parsoid "prefix", see below (optional)
    'prefix' => 'localhost'
);

Here is my mwAPIs file:

mwApis:
        - # This is the only required parameter,
          # the URL of you MediaWiki API endpoint.
          uri: 'http://localhost/w/api.php'
          # The "domain" is used for communication with Visual Editor
          # and RESTBase.  It defaults to the hostname portion of
          # the `uri` property above, but you can manually set it
          # to an arbitrary string. It must match the "domain" set
          # in $wgVirtualRestConfig.
          # domain: 'localhost'  # optional
          # To specify a proxy (or proxy headers) specific to this prefix
          # (which overrides defaultAPIProxyURI). Alternatively, set `proxy`
          # to `null` to override and force no proxying when a default proxy
          # has been set.
          #proxy:
          #    uri: 'http://my.proxy:1234/'
          #    headers:  # optional
          #        'X-Forwarded-Proto': 'https'
          # See below, defaults to true.
          #strictSSL: false

Could someone please help by giving me a pointer or two as to why I cannot load the Editor? Thanks in advance. Also, if I have posted this in the wrong place (not my intention at all) please let me know where I need to be posting this.

Thanks,
Ken

Event Timeline

Aklapper renamed this task from Visual Editor Installation to "Error loading data from server: apierror-visualeditor-docserver-http-error: (curl error: 7) Couldn't connect to server.".Sep 28 2019, 11:02 AM
JTannerWMF subscribed.

It looks like this may be a third party challenge, at this time due to work on Talk Pages we can't take on this task, but thank you for taking the steps to file it

Some standard advice for people experiencing this issue might be (not VE/parsoid specific, but for curl error 7 in general):

  • Use the netstat command to verify that parsoid is listening on the desired port
  • Use curl manually on the command line to try to connect to the parsoid api
  • Check to make sure that there are no firewalls that would prevent the connection
  • Verify that SELinux or other sandboxing techniques that may be enabled on your system, do not prevent MediaWiki from making networking connections or parsoid from recieving them.

A couple of members of our team ran into this locally.

After some debugging we could trace this to this error:

RuntimeException: strtolower() doesn't work -- please set the locale to C or a UTF-8 variant such as C.UTF-8

Adding setlocale(LC_CTYPE, 'C'); at the top of the __construct method of vendor/wikimedia/parsoid/src/Config/Env.php fixed it but there's probably a better way to set this e.g. via .htaccess or php.ini

@Jdlrobson That particular flavour of this bug is a recent addition from T291234

here's probably a better way to set this e.g. via .htaccess or php.ini

$wgShellLocale = "C"; in LocalSettings.php

Another instance of this error was fixed via

$wgVirtualRestConfig['modules']['parsoid'] = [
    'url' => 'http://host.docker.internal:8080' . $wgScriptPath . '/rest.php',
];
matmarex claimed this task.
matmarex added a project: MW-1.41-notes.
matmarex subscribed.

This problem should no longer occur on MediaWiki 1.41 and later, as VisualEditor no longer uses HTTP requests internally to contact Parsoid, it just calls the PHP methods directly (see T320529 for related work).

Please try MediaWiki 1.41 and hopefully VisualEditor will now finally just work. If you still encounter some issues, please file a new task.