Wikimedia Developer Support

Visual Editor and MediaWiki - Couldn't connect to server


#1

VisualEditor 1.32

Mediawiki 1.32

Parsoid 0.10.0

Error:
apierror-visualeditor-docserver-http-error: (curl error: 7) Couldn't connect to server

The regular editor works. The database works.

What is wrong? Whatever I do, it does not help me. I try manual install to Arch - always the same error.

docker-compose.yml:

version: '3'
services:
  mediawiki:
    build: .
    image: amediawiki32ve
    container_name: mediawiki_wiki
    restart: always
    ports:
      - 8024:80
    links:
      - database
      - parsoid
    volumes:
      - /var/www/html/images
      # After initial setup, download LocalSettings.php to the same directory as
      # this yaml and uncomment the following line and use compose to restart
      # the mediawiki service
      - ./LocalSettings.php:/var/www/html/LocalSettings.php
  database:
    image: mariadb
    restart: always
    environment:
      # @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
      MYSQL_DATABASE: my_wiki
      MYSQL_USER: pscn
      MYSQL_PASSWORD: example1
      MYSQL_RANDOM_ROOT_PASSWORD: "yes"
    ports:
      - 4675:3306
  parsoid:
    image: thenets/parsoid:0.10.0
    ports:
      - 8035:8000
    restart: always
    environment:
      PARSOID_DOMAIN_localhost: localhost:8024/api.php

Dockerfile to build:

FROM mediawiki:1.32

RUN cd /var/www/html/extensions &&\
    git clone -b REL1_32 https://gerrit.wikimedia.org/r/p/mediawiki/extensions/VisualEditor.git &&\
    cd VisualEditor &&\
    git submodule update --init

LocalSettings.php (together with automatically generated settings):

$wgDefaultUserOptions['visualeditor-enable'] = 1;
$wgHiddenPrefs[] = 'visualeditor-enable';
$wgVirtualRestConfig['modules']['parsoid'] = array(
    'url' => 'localhost:8035',
    'domain' => 'localhost'
);

When click Edit:
http://localhost:8024/api.php?action=visualeditor&format=json&paction=parse&page=Strona_główna&uselang=pl&oldid=3

{"error":{"code":"apierror-visualeditor-docserver-http-error","info":"(curl error: 7) Couldn't connect to server","*":"See http://localhost:8024/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes."}}

And:
http://localhost:8024/load.php?debug=false&lang=pl&modules=diffMatchPatch,papaparse,rangefix,spark-md5,treeDiffer,unicodejs|ext.visualEditor.articleTarget,base,core,data,desktopArticleTarget,desktopTarget,diffing,icons,language,mediawiki,moduleIcons,mwalienextension,mwcore,mwextensionmessages,mwextensions,mwformatting,mwgallery,mwimage,mwlanguage,mwlink,mwmeta,mwsave,mwsignature,mwtransclusion,welcome|ext.visualEditor.core.desktop|ext.visualEditor.mwextensions.desktop|ext.visualEditor.mwimage.core|jquery.uls.data|mediawiki.action.view.redirectPage|mediawiki.diff.styles|mediawiki.language.names|mediawiki.page.gallery.styles|mediawiki.skinning.content.parsoid|mediawiki.widgets|mediawiki.widgets.MediaSearch,UserInputWidget|oojs-ui.styles.icons-layout,icons-user,icons-wikimedia&skin=vector&version=0ixr96x

And:
http://localhost:8024/api.php

{"options":"success"}


#2

Your error logs say 8024, but your docker-compose say 8035. The ports should match the LocalSettings.php 'url'. Read more about this here.


#3

mediawiki API is in 8024, but parsoid is in separate container in port 8035.

I read that.
I did everything according to those instructions.


#4

Oh sorry I misread what your post. What is the output on doing this from your host’s terminal?

curl -L http://localhost:8035/localhost/v3/page/html/<pagename>/.


#5

For this curl -L http://localhost:8035/localhost/v3/page/html/Strona_główna/:

error: Config Request failure for &quot;localhost:8024/api.php&quot;: Error: Invalid protocol: localhost: path: /localhost/v3/page/html/Strona_gÅówna/
Error: Config Request failure for &quot;localhost:8024/api.php&quot;: Error: Invalid protocol: localhost:
    at ConfigRequest.ApiRequest._requestCB (/var/lib/parsoid/lib/mw/ApiRequest.js:417:15)
    at Request.request [as _callback] (/var/lib/parsoid/lib/mw/ApiRequest.js:335:35)
    at self.callback (/var/lib/parsoid/node_modules/request/request.js:185:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.init (/var/lib/parsoid/node_modules/request/request.js:454:17)
    at new Request (/var/lib/parsoid/node_modules/request/request.js:127:8)
    at request (/var/lib/parsoid/node_modules/request/index.js:53:10)
    at ConfigRequest.ApiRequest.request (/var/lib/parsoid/lib/mw/ApiRequest.js:334:9)
    at ConfigRequest.ApiRequest._requestCB (/var/lib/parsoid/lib/mw/ApiRequest.js:414:9)
    at Request.request [as _callback] (/var/lib/parsoid/lib/mw/ApiRequest.js:335:35)
    at self.callback (/var/lib/parsoid/node_modules/request/request.js:185:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.init (/var/lib/parsoid/node_modules/request/request.js:454:17)
    at new Request (/var/lib/parsoid/node_modules/request/request.js:127:8)

#6

See what happens when you change 'url' in LocalSettings.php from 'localhost:8035' to 'http://localhost:8035'.


#7

With this, no change:
curl -L http://localhost:8035/localhost/v3/page/html/Strona_główna/

error: Config Request failure for &quot;localhost:8024/api.php&quot;: Error: Invalid protocol: localhost: path: /localhost/v3/page/html/Strona_gÅówna/
Error: Config Request failure for &quot;localhost:8024/api.php&quot;: Error: Invalid protocol: localhost:
    at ConfigRequest.ApiRequest._requestCB (/var/lib/parsoid/lib/mw/ApiRequest.js:417:15)
    at Request.request [as _callback] (/var/lib/parsoid/lib/mw/ApiRequest.js:335:35)
    at self.callback (/var/lib/parsoid/node_modules/request/request.js:185:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.init (/var/lib/parsoid/node_modules/request/request.js:454:17)
    at new Request (/var/lib/parsoid/node_modules/request/request.js:127:8)
    at request (/var/lib/parsoid/node_modules/request/index.js:53:10)
    at ConfigRequest.ApiRequest.request (/var/lib/parsoid/lib/mw/ApiRequest.js:334:9)
    at ConfigRequest.ApiRequest._requestCB (/var/lib/parsoid/lib/mw/ApiRequest.js:414:9)
    at Request.request [as _callback] (/var/lib/parsoid/lib/mw/ApiRequest.js:335:35)
    at self.callback (/var/lib/parsoid/node_modules/request/request.js:185:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.init (/var/lib/parsoid/node_modules/request/request.js:454:17)
    at new Request (/var/lib/parsoid/node_modules/request/request.js:127:8)

#8

$wgVirtualRestConfig is the RESTBase URL used by MediaWiki. What’s wrong here is the MediaWiki URL used by RESTBase. You need to fix mwApis.uri in Parsoid’s config.yaml instead.


#9

This is generated by the parsoid container by the environment variable PARSOID_DOMAIN_localhost
I’ve tried this before. It’s not helping.

But I used a different container that has parsoid and visual editor. And it works.
I will compare my version and the one that works. I will check what I do wrong.


#10

Set:
In LocalSettings.php:
'url' => 'parsoid:8000',
In docker-compose.yml:
PARSOID_DOMAIN_localhost: http://mediawiki:80/api.php

And done.
The addresses were guilty.