Topic on Talk:Parsoid

Parsoid installation with Visual Editor / mwoffliner.js: Error loading data from server: 404: parsoidserver-http: HTTP 404

8
Summary by Arlolra

The private _wikitext and _html routes require devAPI: true to your config.yaml

Escalatr (talkcontribs)

Hello,

I am trying to install Parsoid in order to use the https://github.com/kiwix/mwoffliner script for dumping my MediaWiki for offline usage in http://www.kiwix.org/ first. Using the Visual Editor would be also nice later.

The mediawiki is running inside an intranet at http://172.18.200.40/himtwiki/, I have disabled short URLs for now, it is a private wiki.

$wgGroupPermissions['*'    ]['read']            = false;
  • The system is running on openSUSE 13.1 (Bottle) (x86_64).
  • MediaWiki: 1.25
  • Parsoid: 0.6.1 / 2016-11-14
  • NodeJS: v4.2.4
  • I followed the steps from Parsoid/Developer Setup
  • Parsoid resides in /root/parsoid/ for testing now
  • Created config.yaml as following:
        # Configure Parsoid to point to your MediaWiki instances.
        mwApis:
        - # This is the only required parameter,
          # the URL of you MediaWiki API endpoint.
          uri: 'http://172.18.200.40/himtwiki/api.php'
          # The "domain" is used for communication with Visual Editor
          # and RESTBase.  It defaults to the hostname portion of
          # the `uri` property below, but you can manually set it
          # to an arbitrary string.
          domain: 'localhost'  # optional
          prefix: 'localhost'
  • Service is running node bin/server.js
    • Update: Command line output added
{"name":"parsoid","hostname":"server223","pid":793,"level":30,"levelPath":"info/service-runner","msg":"master(793) initializing 4 workers","time":"2017-02-07T13:08:11.107Z","v":0}
{"name":"lib/index.js","hostname":"server223","pid":802,"level":30,"levelPath":"info","msg":"loading ...","time":"2017-02-07T13:08:11.858Z","v":0}
{"name":"lib/index.js","hostname":"server223","pid":802,"level":30,"levelPath":"info","msg":"ready on :8000","time":"2017-02-07T13:08:11.879Z","v":0}
{"name":"lib/index.js","hostname":"server223","pid":807,"level":30,"levelPath":"info","msg":"loading ...","time":"2017-02-07T13:08:12.637Z","v":0}
{"name":"lib/index.js","hostname":"server223","pid":807,"level":30,"levelPath":"info","msg":"ready on :8000","time":"2017-02-07T13:08:12.656Z","v":0}
{"name":"lib/index.js","hostname":"server223","pid":812,"level":30,"levelPath":"info","msg":"loading ...","time":"2017-02-07T13:08:13.403Z","v":0}
{"name":"lib/index.js","hostname":"server223","pid":812,"level":30,"levelPath":"info","msg":"ready on :8000","time":"2017-02-07T13:08:13.422Z","v":0}
{"name":"lib/index.js","hostname":"server223","pid":817,"level":30,"levelPath":"info","msg":"loading ...","time":"2017-02-07T13:08:14.171Z","v":0}
{"name":"lib/index.js","hostname":"server223","pid":817,"level":30,"levelPath":"info","msg":"ready on :8000","time":"2017-02-07T13:08:14.189Z","v":0}
{"name":"parsoid","hostname":"server223","pid":793,"level":40,"levelPath":"warn/service-runner","msg":"Startup finished","time":"2017-02-07T13:08:14.190Z","v":0}

Visual Editor

  • I have also went through the Visual Editor installation, which is not working, I get the button Edit source for editing only (Visual Editor is actually enabled in the user preferences).
    • Update: $wgVisualEditorNamespaces = array(NS_MAIN, NS_USER); was missing in my LocalSettings.php, now I can try to edit existing pages the Visual Editor, but it fails with Error loading data from server: 404: parsoidserver-http: HTTP 404, now I am looking at other users´ issues with the same error, but nothing has helped so far.

LocalSettings.php:

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'
);
$wgSessionsInObjectCache = true;

Settings for private wiki from https://www.mediawiki.org/wiki/Extension:VisualEditor#Linking_with_Parsoid_in_private_wikis are added:

// This feature requires a non-locking session store. The default session store will not work and
// will cause deadlocks (connection timeouts from Parsoid) when trying to use this feature.
$wgSessionsInObjectCache = true;

// Forward users' Cookie: headers to Parsoid. Required for private wikis (login required to read).
// If the wiki is not private (i.e. $wgGroupPermissions['*']['read'] is true) this configuration
// variable will be ignored.
//
// WARNING: ONLY enable this on private wikis and ONLY IF you understand the SECURITY IMPLICATIONS
// of sending Cookie headers to Parsoid over HTTP. For security reasons, it is strongly recommended
// that $wgVirtualRestConfig['modules']['parsoid']['url'] be pointed to localhost if this setting is enabled.
$wgVirtualRestConfig['modules']['parsoid']['forwardCookies'] = true;

Thanks in advance

Arlolra (talkcontribs)

The _wikitext and _html routes are intended to be private, for development use only. To enable them, add devAPI: true to your config.yaml

Escalatr (talkcontribs)

Thanks for the remark, devAPI: true indeed enabled _wikitext output! This topic is at least partially solved.

However, Visual Editor and mwoffliner.js still fail with the error Error loading data from server: 404: parsoidserver-http: HTTP 404

Arlolra (talkcontribs)

Sounds like Parsoid itself is configured correctly now. Try setting the url in the $wgVirtualRestConfig in your LocalSetting.php to http://172.18.200.40:8000, since that's what you tested above.

Escalatr (talkcontribs)

Thanks for the reply, I tried several URLs already:

The page http://172.18.200.40:8000/localhost/v3/page/html/Main_Page/ is always working, however Visual Editor fails. The only difference with http://localhost:8000 and http://127.0.0.1:8000: the parsed page seems to be missing CSS files (I am seeing the default browser font and formatting).

I am quite unclear how domain and prefix should be configured, the documentation is rather contradictory, have tried several settings already.

I have started a thread with some more information at Visual Editor discussion: https://www.mediawiki.org/wiki/Topic:Tkngrm2kaak25q8o. Parsoid seems to work properly in general. Just the connection by VisualEditor and mwoffliner.js fails.

Escalatr (talkcontribs)

According to https://www.mediawiki.org/wiki/Offline_content_generator/Installation/en#Starting I called netstat -tuln, the output:

server223:/etc/init.d # netstat -tuln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:9200            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:9300            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:6556            0.0.0.0:*               LISTEN
tcp        0      0 :::8000                 :::*                    LISTEN
tcp        0      0 :::873                  :::*                    LISTEN
tcp        0      0 :::3306                 :::*                    LISTEN
tcp        0      0 :::22                   :::*                    LISTEN
udp        0      0 0.0.0.0:57053           0.0.0.0:*
udp        0      0 0.0.0.0:57231           0.0.0.0:*
udp        0      0 0.0.0.0:33014           0.0.0.0:*
udp        0      0 0.0.0.0:54328           0.0.0.0:*
udp        0      0 0.0.0.0:5353            0.0.0.0:*
udp        0      0 0.0.0.0:43376           0.0.0.0:*
udp        0      0 0.0.0.0:47603           0.0.0.0:*
udp        0      0 :::38093                :::*
udp        0      0 :::5353                 :::*
Arlolra (talkcontribs)

The colons indicate that it's listening on IPv6 addresses as well. That seems ok since you were able to reach the IPv4 address 172.18.200.40

No, Redis is not required in any way.

Escalatr (talkcontribs)

Thanks for the clarification.