Page MenuHomePhabricator

Visual editor returns following error code: `Error loading data from server: apierror-visualeditor-docserver-http-error: (curl error: 7) Couldn't connect to server. Would you like to retry`
Closed, ResolvedPublic

Description

HI,

I'm new to Mediawiki. I'm also new to development. I'm a UX Designer learning code, so I'm kind of a beginner with this stuff and I apologize if this is the wrong place to place this information.

This may be just a set up error but perhaps it can also help give information to the devs on the user experience of set up etc.

I am unable to use Visual Editor to edit pages. A pretty extensive play by play update of my trouble shooting process can be found on the Parsoid talk page here and on the Mediawiki Discourse forum here (though it appears that my discourse post was hidden by the automod as spam because it contained links)

In searching for solutions I found several similar bugs on here and figured this place was the more active location for me to check in with this issue.

The situation as it stands now

I can run curl https://wiki.example.com/api.php and get the correct output.

I can run 'curl http://localhost:8000` and get the Parsoid output page.

When I run curl https://localhost:8000 I get a failure state with the following error:

curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to localhost:8000

When I run curl http://wiki.example.com/w/api.php I get a failure state with a 301 error page.

When I try to use visual editor through my browser using the web interface I get the following error message:

Error loading data from server: apierror-visualeditor-docserver-http-error: (curl error: 7) Couldn't connect to server. Would you like to retry?

So it seems that Visual Editor is set up correctly and Parsoid is running correctly. My guess is that they aren't connecting because my website is running on HTTPS only and Parsoid is trying to run on http only?

What more information can I provide and what can I do to fix this issue?

Additional Server Information
-I'm running an nginx server on my local personal desktop server.
-My domain name is handled by Dreamhost, who I also use to host my personal portfolio website.
-Locally I am hosting a NextCloud personal cloud instance under cloud.example.com using virtual hosts.
-Locally I am hosting a Mediawiki personal private wiki instance under wiki.example.com using virtual hosts.
-Locally I am hosting a DokuWiki personal private wiki instance under doku.example.com using virtual hosts.
-I have valid current letsencrypt certs for all three sites.

Event Timeline

@Thedonquixotic You've got multiple threads going on https://www.mediawiki.org/wiki/Talk:Parsoid and https://discourse-mediawiki.wmflabs.org/ and now here on Phabricator.

Can you please pick the location you're most comfortable and we'll help you there? Thanks

Thank you @Arlolra I'm sorry to have been all over the place. Part of the problem is that it's not really clear to me what is the preferred place for what issues by the Mediawiki community. The talk pages do not seem very well equipped for in depth troubleshooting discussions due to their format, nor do they seem very active. The Discourse forum seems pretty much dead and I got flagged by the automod there so I'm not even sure if anyone can see my post. This place seems to be the best equipped to discuss things though I'm not sure if I'm putting stuff in the right place.

For now though I'm willing to settle here. I think it might be helpful for the Mediawiki org if there was some sort of explicit policy on what locations were for what kind of discussion.

Is it fair to say that your current status is where we left on https://www.mediawiki.org/w/index.php?title=Topic:Umuo9t5f9ox3umdq&topic_showPostId=umvhwzu6vyhzj3xr#flow-post-umvhwzu6vyhzj3xr

You've manually started Parsoid running on port 8000 and can curl the welcome page?

If so, can you paste what you've got in your config.yaml

mwApis:
        - # This is the only required parameter,
          # the URL of you MediaWiki API endpoint.
          uri: 'https://wiki.jackalope.tech/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: 'wiki.jackalope.tech'  # optional

I can only curl the parsoid welcome page via http though, and my mediawiki install is https.

My hunch is the issue is related to my wiki being private and using ssl only. So I looked that up and found this troubleshooting here and I've tried following it. My understanding is that Parsoid can't connect over https so to do that I have to set up a tunnel between 8143 and 8000. I have set stuff up but when I go to https://wiki.example.com:8143 I get a "can't connect" error.

Ok, so presumably curl http://localhost:8000/wiki.jackalope.tech/v3/page/html/Main_Page will render your main page now.

Can we see your LocalSettings.php as well?

Yes, that is correct.

Here's the full localsettings.php file. I've ommitted private info but am giving the whole thing in case there is some x-factor of it that is messing things up:

<?php
# This file was automatically generated by the MediaWiki 1.32.0-alpha
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
#
# See includes/DefaultSettings.php for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.
#
# Further documentation for configuration settings may be found at:
# https://www.mediawiki.org/wiki/Manual:Configuration_settings

# Protect against web entry
if (!defined('MEDIAWIKI')) {
    exit;
}

$wgSitename = "Λόγος";

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "";

## The protocol and server name to use in fully-qualified URLs
$wgServer = "https://wiki.jackalope.tech";

## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;

## The URL path to the logo.  Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogo = "$wgResourceBasePath/resources/assets/wiki.png";

## UPO means: this is also a user preference option

$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO

$wgEmergencyContact = "omitted";
$wgPasswordSender = "omitted";

$wgEnotifUserTalk = true; # UPO
$wgEnotifWatchlist = true; # UPO
$wgEmailAuthentication = true;

## Database settings
$wgDBtype = "omitted";
$wgDBserver = "omitted";
$wgDBname = "omitted";
$wgDBuser = "omitted";
$wgDBpassword = "omitted";

# MySQL specific settings
$wgDBprefix = "omitted";

# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

## Shared memory settings
$wgMainCacheType = CACHE_ACCEL;
$wgMemCachedServers = [];

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";

# InstantCommons allows wiki to use images from https://commons.wikimedia.org
$wgUseInstantCommons = false;

# Periodically send a pingback to https://www.mediawiki.org/ with basic data
# about this MediaWiki instance. The Wikimedia Foundation shares this data
# with MediaWiki developers to help guide future development efforts.
$wgPingback = true;

## If you use ImageMagick (or any other shell command) on a
## Linux server, this will need to be set to the name of an
## available UTF-8 locale
$wgShellLocale = "C.UTF-8";

## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publically accessible from the web.
#$wgCacheDirectory = "$IP/cache";

# Site language code, should be one of the list in ./languages/data/Names.php
$wgLanguageCode = "en";

$wgSecretKey = "omitted";

# Changing this will log out all existing sessions.
$wgAuthenticationTokenVersion = "1";

# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "omitted";

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "https://creativecommons.org/licenses/by-nc-sa/4.0/";
$wgRightsText = "Creative Commons Attribution-NonCommercial-ShareAlike";
$wgRightsIcon = "$wgResourceBasePath/resources/assets/licenses/cc-by-nc-sa.png";

# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";

# The following permissions were set based on your choice in the installer
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['edit'] = false;

# End of automatically generated settings.
# Add more configuration options below.

//-SKINS
## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'vector', 'monobook':
$wgDefaultSkin = "vector";
// load vector skin
wfLoadSkin('Vector');
//- EXTENSIONS
//-Visual editor
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' => 'https://wiki.jackalope.tech:8000',
    // Parsoid "domain", see below (optional)
    'domain' => 'wiki.jackalope.tech',
    // Parsoid "prefix", see below (optional)
    'prefix' => 'wiki.jackalope.tech',
);

//- 2017 Wiki Text
// $wgVisualEditorEnableWikitext = true;
// $wgDefaultUserOptions['visualeditor-newwikitext'] = 1;
// $wgHiddenPrefs[] = 'visualeditor-newwikitext';

//- Code Mirror
// wfLoadExtension('CodeMirror');

What happens when you change,

'url' => 'https://wiki.jackalope.tech:8000',

to

'url' => 'http://localhost:8000',

It works!

Just for future references, is there a reason that it works now but wasn't before? Is the localhost:8000 not supposed to be my domain name etc?

Arlolra claimed this task.

Well, you haven't configured Parsoid to listen for HTTPS connections on port 8000, only HTTP. But also, you probably aren't exposing 8000 for external connections (through your firewall, or whathaveyou) so only connections to the loopback address (localhost) are connecting. Parsoid might not also be listening for that specific host (your domain).

The way MediaWiki is configured now is fine because it's running on the same server so doesn't need a TLS connection to Parsoid. And Parsoid doesn't need to be exposed externally.

The request flow is described here,
https://www.mediawiki.org/w/index.php?title=Topic:Uiunyi6pkqp5vgz1&topic_showPostId=ujb7ciqv8t4dunxr#flow-post-ujb7ciqv8t4dunxr

However, as it stands, you've set Parsoid's config.yaml to connect to,

uri: 'https://wiki.jackalope.tech/api.php'

That might look better as,

uri: 'http://localhost/api.php'

or however MediaWiki is setup locally. But then you'd need to one of the things you linked to,
https://www.mediawiki.org/wiki/Extension:VisualEditor#Linking_with_Parsoid_in_private_wikis

like,
https://www.mediawiki.org/wiki/User:Andrujhon/Allow_Parsoid_Server

Thank you @Arlolra

If I can ask a quick follow up question. How would I configure Parsoid to listen to https connection? The only place I understand that I need to configure are the config.yaml file and the LocalSettings.php file. The LocalSettings file allows me to specify the 8000 but the parsoid config file doesn't seem to have that from what I can tell in the documentation?

@Arlolra Awesome thank you.

Also just out of curiosity but shouldn't this patch be enabled in mediawiki installs by default nowadays? I'm new to development so maybe I'm missing something but https is basically considered standard min requirement for all new websites ever since Chrome and Mozilla started blocking them and requiring opt-in security exceptions, and Google and Bing are significantly lowering their SEO results. It seems like this should be standard, right?

Your MediaWiki instance is served with TLS.

Parsoid isn't (or doesn't need to be) exposed to external connections. It's an internal service that communicates with MediaWiki. In T207504#4681846, I pointed to a description of the request flow, which I'll paste here,

VE (browser) -> MediaWiki API -> Parsoid -> MediaWiki API

I'm also gettting a "(curl error: 7) Couldn't connect to server"

I'm looking at the above config.yaml but it's different from mine:

worker_heartbeat_timeout: 300000

logging:
    level: info

services:
  - module: lib/index.js
    entrypoint: apiServiceWorker
    conf:
        localsettings: ./localsettings.js

Localsettings.php :

<?php
# This file was automatically generated by the MediaWiki 1.31.9
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
#
# See includes/DefaultSettings.php for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.
#
# Further documentation for configuration settings may be found at:
# https://www.mediawiki.org/wiki/Manual:Configuration_settings

# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
	exit;
}


## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;

$wgSitename = "Cid Systems";
$wgMetaNamespace = "Cid_Systems";

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "";

## The protocol and server name to use in fully-qualified URLs
$wgServer = "https://docs.cid-systems.com";

## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;

## The URL path to the logo.  Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogo = "$wgResourceBasePath/resources/assets/wiki.png";

## UPO means: this is also a user preference option

$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO

$wgEmergencyContact = "lumeng.lim@gmail.com";
$wgPasswordSender = "lumeng.lim@gmail.com";

$wgEnotifUserTalk = true; # UPO
$wgEnotifWatchlist = true; # UPO
$wgEmailAuthentication = true;

## Database settings
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "docscids_wiki";
$wgDBuser = "docscids_wiki";
$wgDBpassword = "4[Q@8{;N+nrX";

# MySQL specific settings
$wgDBprefix = "";

# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

## Shared memory settings
$wgMainCacheType = CACHE_DB;
#$wgMainCacheType = CACHE_ACCEL;
$wgMemCachedServers = [];

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";

# InstantCommons allows wiki to use images from https://commons.wikimedia.org
$wgUseInstantCommons = false;

# Periodically send a pingback to https://www.mediawiki.org/ with basic data
# about this MediaWiki instance. The Wikimedia Foundation shares this data
# with MediaWiki developers to help guide future development efforts.
$wgPingback = false;

## If you use ImageMagick (or any other shell command) on a
## Linux server, this will need to be set to the name of an
## available UTF-8 locale
$wgShellLocale = "en_US.utf8";

## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publically accessible from the web.
#$wgCacheDirectory = "$IP/cache";

# Site language code, should be one of the list in ./languages/data/Names.php
$wgLanguageCode = "en";

$wgSecretKey = "3232d95a9a496e2f8d2a5babb307ffddefc5e890f48013cddad33d5c0df64a79";

# Changing this will log out all existing sessions.
$wgAuthenticationTokenVersion = "1";

# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "6b0a9379821fb4fc";

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";

# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";

## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'vector', 'monobook':
$wgDefaultSkin = "bluespicecalumma";

# End of automatically generated settings.
# Add more configuration options below.


# This is the main settings file for all BlueSpice extensions and settings
# It will include all files in "$IP/settings.d/" directory
require_once "$IP/LocalSettings.BlueSpice.php";


$wgUserMergeProtectedGroups = array();
$wgUserMergeUnmergeable = array();
$wgMetaNamespace = 'Project';
$bsgGroupRoles['*']['reader'] = false;

# Convenience for debugging
# $wgShowSQLErrors = true;
# $wgDebugDumpSql  = true;
# $wgShowExceptionDetails = true;
# $wgShowDBErrorBacktrace = true;