【问题标题】:MediaWiki 1.35 parsoid timeout trying use VisualEditorMediaWiki 1.35 parsoid 超时尝试使用可视化编辑器
【发布时间】:2020-10-19 20:37:19
【问题描述】:

我在 Amazon ec2 服务器上安装了 mediawiki。
服务器只有apache、php、mariadb和mediawiki

我使用的是 mediawiki 1.35,捆绑了 VisualEditor 和 ParsoidPHP
我可以使用可视化编辑器编辑新页面,但它不会保存,当我编辑现有页面时,我会看到蓝色进度条,然后出现错误:
联系 Parsoid/RESTBase 服务器时出错:( curl 错误:28) 已超时
我尝试使用我在网上找到的说明配置 parsoid:

$wgVirtualRestConfig['modules']['parsoid'] = [
        // URL to the Parsoid instance - use port 8142 if you use the Debian package - the parameter 'URL' was first used but is now deprecated (string)
        'url' => 'http://myIpAddress:8000',
        // Parsoid "domain" (string, optional) - MediaWiki >= 1.26
        'domain' => 'myIpAddress',
        // Parsoid "prefix" (string, optional) - deprecated since MediaWiki 1.26, use 'domain'
        'prefix' => 'myIpAddress',
        // Forward cookies in the case of private wikis (string or false, optional)
        'forwardCookies' => true,
        // request timeout in seconds (integer or null, optional)
        'timeout' => null,
        // Parsoid HTTP proxy (string or null, optional)
        'HTTPProxy' => null,
        // whether to parse URL as if they were meant for RESTBase (boolean or null, optional)
        'restbaseCompat' => null,
];

我得到的最佳效果是 404 或 400。此配置不起作用。
我没有对设置进行任何其他更改。

如果我直接调用 parsoid:
http://MyIpAddress/api.php?action=visualeditor&paction=parse&page=Main_Page

我因此看到了超时:

{
    "error": {
        "code": "apierror-visualeditor-docserver-http-error",
        "info": "Error contacting the Parsoid/RESTBase server: (curl error: 28) Timeout was reached",
        "*": "See http://MyIpAddress/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."
    }
}

【问题讨论】:

  • 如果你根本不碰$wgVirtualRestConfig,它应该可以开箱即用。
  • 我花了很多时间处理错误后才添加配置。无论是否存在,我都会收到错误消息。
  • Parsoid 模块的配置非空导致错误(尽管通常我希望有一个不同的错误) - 请参阅this check

标签: mediawiki


【解决方案1】:

根据我的测试,parsoid 似乎正在使用 $wgServer 变量与 rest.php 建立本地连接
使用 curl,我可以连接到 http://localhost/rest.php/v1/page/Main_Page
但是,不是 http://myipaddress/rest.php/v1/page/Main_Page 或 http://mydomainname/rest.php/v1/page/Main_Page 两者这些超时。 apache 服务器无法连接到自身
所以,理论上,我应该可以设置

$wgVirtualRestConfig['modules']['parsoid']['domain']='localhost';

但这会导致 404,而不是超时。

最后,我将我的域名添加到 /etc/hosts 并将其指向 127.0.0.1 并且效果很好。感觉就像 hack,我必须使用域名,而不仅仅是 iP。

【讨论】:

    【解决方案2】:

    我们已经多次遇到这个问题。

    在一种情况下,这是一个访问控制问题。

    Parsoid 向 MediaWiki 站点发出 HTTP 请求。我们使用the Lockdown extension 限制对某些操作的访问, 我们必须豁免 Parsoid,这可以通过多种方式完成,例如:

    if (($_SERVER['REMOTE_ADDR'] !== '127.0.0.1') && ($_SERVER['REMOTE_ADDR'] !== $_
    SERVER['SERVER_ADDR'])) {
    # don't lock down any pages for Parsoid, or the VisualEditor will break on them
        wfLoadExtension('Lockdown');
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-04
      • 2023-01-29
      • 1970-01-01
      • 1970-01-01
      • 2015-01-31
      • 1970-01-01
      • 2016-01-05
      • 2015-05-08
      相关资源
      最近更新 更多