Omeka S and module Scripto error

Hi,

I have an Omeka S v2.1.2.

I have installed mediawiki v1.31.1 and a Scripto v1.0.0 module from Omeka Team.

And when I enter the api endpoint of mediawiki (http://sample.fr/api.php), I get the following error :

image

If I enter this Url in my browser, I get to the MediaWiki API help page.

Does anyone have any ideas ?

Thank you in advance

Hi,

Try with the v1.2.0 of Scripto module and take care of https:// in the endpoint url.

It’s the normal way to have the MW help page on /api.php

Franck.

That error message is unhelpful, but it does indicate that your API URL is invalid. Double-check the URL by entering it into your browser. You should see a page that displays “MediaWiki API help.” If not, it’s not a valid API URL.

Hi,

Thank you for your answers, but none of them solve the problem.

I can’t try with the v1.2 of the Scripto module because it’s only compatible with Omeka S V3 and I have a V1.2.1.

I switched mediawiki to https instead of http and it doesn’t change anything.

And as I said in my message, API URL is valid :

  • https ://urlmediawiki/api.php : I can access the Mediawiki API help page.

  • https://urlmediawiki: I have good access to the Mediawiki home page, and I can log in

Do you have another idea?
Thanks in advance

Hmm. Omeka’s HTTP client may be having trouble connecting to MediaWiki due to an SSL error. Try this: open /config/local.config.php and change this:

    'http_client' => [
        'sslcapath' => null,
        'sslcafile' => null,
    ],

To this:

    'http_client' => [
        'adapter' => \Zend\Http\Client\Adapter\Curl::class,
        'sslcapath' => null,
        'sslcafile' => null,
    ],

By declaring the Curl adapter, it works.

But, we are behind a Proxy and before we had declared in the config/local.config.php file, the Proxy adapter.

'http_client' => [
    'adapter' => \Zend\Http\Client\Adapter\Proxy::class,
    'sslcapath' => null,
    'sslcafile' => null,
],

In the vendor/zendframework/zend-http/Client.php file, we also declared the Proxy Adapter :

    'adapter' => Proxy::class,

and in the file vendor/zendframework/zend-http/Client/Adapter/Proxy.php our proxy_host.

Do you think that declaring the Curl Adapter in the local_config.php file will cause problems when operations will require to get out ?

In any case, thank you.

We haven’t encountered this problem before. It’s odd that you can navigate to the MediaWiki API in a browser but the Proxy adapter can’t do the same. It’ll be helpful to get the actual error that the client throws when you use the Proxy adapter.

Change your adapter back to Proxy. Open /module/Scripto/src/Form/ModuleConfigForm.php and change this:

    public function apiIsValid($apiUrl, $context)
    {
        try {
            $client = new ApiClient($this->httpClient, $apiUrl, $this->timeZone);
        } catch (\Exception $e) {
            // Not a resolvable URL
            return false;
        }
        if (!is_array($client->querySiteInfo())) {
            // Not a MediaWiki API endpoint
            return false;
        }
        if (version_compare($client->getVersion(), ApiClient::MINIMUM_VERSION, '<')) {
            // The MediaWiki version is invalid
            return false;
        }
        return true;
    }

To this:

    public function apiIsValid($apiUrl, $context)
    {
        try {
            $client = new ApiClient($this->httpClient, $apiUrl, $this->timeZone);
            if (!is_array($client->querySiteInfo())) {
                // Not a MediaWiki API endpoint
                return false;
            }
            if (version_compare($client->getVersion(), ApiClient::MINIMUM_VERSION, '<')) {
                // The MediaWiki version is invalid
                return false;
            }
        } catch (\Exception $e) {
            echo $e;exit;
            return false;
        }
        return true;
    }

You should see a stack trace that will tell us exactly what’s going on.

After I made the modification of ModuleConfigForm.php, I get the following message :

Invalid MediaWiki API. The URL must resolve to a MediaWiki API endpoint and the MediaWiki version must be 1.30.0 or greater.

And this is not the case, because the version of our Mediawiki server is V1.31.1, as you can see in the rest of my message.

I tried to take a closer look and trace what was going on.

The problem seems to occur in the request function in Scripto/src/Mediawiki/apiClient.php,

public function request(array $params = [])

{
$params[‘format’] = ‘json’;
$params[‘formatversion’] = ‘2’;
$request = new Request;
$request->setUri($this->apiUrl);
$request->setMethod(Request::METHOD_POST);
$request->getPost()->fromArray($params);
$response = $this->httpClient->send($request);

if ($response->isSuccess()) {
return json_decode($response->getBody(), true);
}
throw new Exception\RequestException($response->renderStatusLine());
}

The contents of $request is :
POST http://vdomekas18.intra.inist.fr:40001/api.php HTTP/1.1

The contents of $responses is :
HTTP/1.0 404 Not Found
Date: Fri, 18 Dec 2020 08:43:03 GMT
Server: Apache/2.4.29 (Ubuntu)
Content-Length: 287
Content-Type: text/html; charset=iso-8859-1
X-Cache: MISS from proxyout.inist.fr
X-Cache-Lookup: MISS from proxyout.inist.fr:8080
Connection: close

404 Not Found
The requested URL was not found on this server.
Apache/2.4.29 (Ubuntu) Server at vdomekas18.intra.inist.fr Port 80

Or

Array ( [action] => query [meta] => siteinfo [format] => json [formatversion] => 2 ) Zend\Http\Response Object ( [recommendedReasonPhrases:protected] => Array ( [100] => Continue [101] => Switching Protocols [102] => Processing [200] => OK [201] => Created [202] => Accepted [203] => Non-Authoritative Information [204] => No Content [205] => Reset Content [206] => Partial Content [207] => Multi-status [208] => Already Reported [226] => IM Used [300] => Multiple Choices [301] => Moved Permanently [302] => Found [303] => See Other [304] => Not Modified [305] => Use Proxy [306] => Switch Proxy [307] => Temporary Redirect [308] => Permanent Redirect [400] => Bad Request [401] => Unauthorized [402] => Payment Required [403] => Forbidden [404] => Not Found [405] => Method Not Allowed [406] => Not Acceptable [407] => Proxy Authentication Required [408] => Request Time-out [409] => Conflict [410] => Gone [411] => Length Required [412] => Precondition Failed [413] => Request Entity Too Large [414] => Request-URI Too Long [415] => Unsupported Media Type [416] => Requested range not satisfiable [417] => Expectation Failed [418] => I’m a teapot [422] => Unprocessable Entity [423] => Locked [424] => Failed Dependency [425] => Too Early [426] => Upgrade Required [428] => Precondition Required [429] => Too Many Requests [431] => Request Header Fields Too Large [444] => Connection Closed Without Response [451] => Unavailable For Legal Reasons [499] => Client Closed Request [500] => Internal Server Error [501] => Not Implemented [502] => Bad Gateway [503] => Service Unavailable [504] => Gateway Time-out [505] => HTTP Version not supported [506] => Variant Also Negotiates [507] => Insufficient Storage [508] => Loop Detected [510] => Not Extended [511] => Network Authentication Required [599] => Network Connect Timeout Error ) [statusCode:protected] => 404 [reasonPhrase:protected] => Not Found [version:protected] => 1.0 [headers:protected] => Zend\Http\Headers Object ( [pluginClassLoader:protected] => [headersKeys:protected] => Array ( [0] => date [1] => server [2] => content-length [3] => content-type [4] => x-cache [5] => x-cache-lookup [6] => connection ) [headers:protected] => Array ( [0] => Array ( [name] => Date [line] => Date: Fri, 18 Dec 2020 08:47:00 GMT ) [1] => Array ( [name] => Server [line] => Server: Apache/2.4.29 (Ubuntu) ) [2] => Array ( [name] => Content-Length [line] => Content-Length: 287 ) [3] => Array ( [name] => Content-Type [line] => Content-Type: text/html; charset=iso-8859-1 ) [4] => Array ( [name] => X-Cache [line] => X-Cache: MISS from proxyout.inist.fr ) [5] => Array ( [name] => X-Cache-Lookup [line] => X-Cache-Lookup: MISS from proxyout.inist.fr:8080 ) [6] => Array ( [name] => Connection [line] => Connection: close ) ) ) [metadata:protected] => Array ( ) [content:protected] =>

With the Curl Adapter, you get the following answer :

HTTP/1.1 200 OK
Date: Fri, 18 Dec 2020 09:38:26 GMT
Server: Apache
X-Powered-By: PHP/7.2.24-0ubuntu0.18.04.7
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Content-Disposition: inline; filename=api-result.json
Set-Cookie: UseDC=master; Max-Age=10; Expires=Fri, 18-Dec-2020 09:38:36 GMT; Path=/; HttpOnly
Set-Cookie: UseCDNCache=false; Max-Age=10; Expires=Fri, 18-Dec-2020 09:38:36 GMT; Path=/; HttpOnly
Vary: Accept-Encoding,Treat-as-Untrusted,Cookie
Cache-Control: max-age=0, must-revalidate, private
Content-Length: 1952
Connection: close
Content-Type: application/json; charset=utf-8

{“batchcomplete”:true,“query”:{“general”:{“mainpage”:“Accueil”,“base”:“http://vdomekas18.intra.inist.fr:4000
1/index.php/Accueil”,“sitename”:“wiki”,“logo”:“http://vdomekas18.intra.inist.fr:40001/resources/assets/wiki.
png”,“generator”:" MediaWiki 1.31.1 “,“phpversion”:“7.2.24-0ubuntu0.18.04.7”,“phpsapi”:“apache2handler”,“dbtype”:“mysql”,“dbversion”:“5.7.32-0ubuntu0.18.04.1-log”,“imagewhitelistenabled”:true,“langconversion”:true,“titleconversion”:true,“linkprefixcharset”:”",“linkprefix”:"",“linktrail”:"/^([a-zàùçéÚĂȘĂźĂŽĂ»Ă€Ă«ĂŻĂ¶ĂŒĂčÇÉÂÊÎÔÛÄËÏÖÜÀÈÙ]+)(.)$/sDu",“legaltitlechars”:" %!"$&’(),\-.\/0-9:;=?@A-Z\\^`a-z~\x80-\xFF+",“invalidusernamechars”:"@:",“allunicodefixes”:false,“fixarabicunicode”:true,“fixmalayalamunicode”:true,“case”:“first-letter”,“lang”:“fr”,“fallback”:[{“code”:“en”}],“rtl”:false,“fallback8bitEncoding”:“windows-1252”,“readonly”:false,“writeapi”:true,“maxarticlesize”:2097152,“timezone”:“Europe/Paris”,“timeoffset”:60,“articlepath”:"/index.php/$1",“scriptpath”:"",“script”:"/index.php",“variantarticlepath”:false,“server”:“http://vdomekas18.intra.inist.fr:40001”,“servername”:“vdomekas18.intra.inist.fr”,“wikiid”:"mediawiki_db-mediawiki",“time”:“2020-12-18T09:38:26Z”,“misermode”:false,“uploadsenabled”:false,“maxuploadsize”:104857600,“minuploadchunksize”:1024,“galleryoptions”:{“imagesPerRow”:0,“imageWidth”:120,“imageHeight”:120,“captionLength”:true,“showBytes”:true,“showDimensions”:true,“mode”:“traditional”},“thumblimits”:{“0”:120,“1”:150,“2”:180,“3”:200,“4”:250,“5”:300},“imagelimits”:{“0”:{“width”:320,“height”:240},“1”:{“width”:640,“height”:480},“2”:{“width”:800,“height”:600},“3”:{“width”:1024,“height”:768},“4”:{“width”:1280,“height”:1024}},“favicon”:“http://vdomekas18.intra.inist.fr:40001/favicon.ico",“centralidlookupprovider”:“local”,“allcentralidlookupproviders”:[“local”],“interwikimagic”:true,“magiclinks”:{“ISBN”:false,“PMID”:false,“RFC”:false},“categorycollation”:"uppercase”}}} - RĂ©ponse is success

I’m surprised that you received that specific error message. I was expecting a message from the HTTP client, like the “404 Not Found” that’s hidden in the response.

No matter. Are you sure you can access the MediaWiki installation from outside your institution? I cannot access http://vdomekas18.intra.inist.fr:40001/api.php - my browser sees it as a non-existent domain. Perhaps your proxy cannot access it? Your server admin may have a better idea why the proxy cannot resolve the MediaWiki URL.

1 Like

I would like to take this opportunity to wish you and the entire Omeka team a happy new year 2021.

This address is not open outside and Mediawiki is installed on the same server as Omeka S. However, access is via proxy. And the returned error is indeed 404.

I traced what happens inside the Proxy.php adapter and more precisely in the write function. And I think I found the explanation.

In fact, in the constitution of the Mediawiki api request, the function removes the character “:” followed by the indication of the port (:40001), in the Url given in the Scripto configuration : http://vdomekas18.intra.inist.fr:40001/api.php.

Request: POST http://vdomekas18.intra.inist.fr/api.php HTTP/1.1

The port indication in the request is missing.

By modifying the Proxy.php module to force it to do so, it looks like this:

Request : POST http://vdomekas18.intra.inist.fr:40001/api.php HTTP/1.1

And now it works.

Conclusion, it is necessary to use a Url without the indication of the port, creating, for example, an accelerator for access to Mediawiki

A post was split to a new topic: Scripto error: stream_socket_client permission denied

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.