5.5.3 XRPC Server

On database startup, the the HTTP server built-in for XRPC is started up automatically:

    $ Mserver --dbinit="module(pathfinder);"
    ...
    # XRPC administrative GUI at http://localhost:50001/admin
    MonetDB>

The Administrative GUI (see The Administrative GUI) is a pure-HTML application that allows to administer MonetDB/XQuery. It is built on top of XRPC and the HTTP port number used is visible in the start-up message above.

By default, the XRPC server listens to the port number (mapi_port + 1). As the default mapi_port number is 50000, the default xrpc_port number is thus 50001 (please note the port number of the XRPC administrative GUI above).

The xrpc_port variable can be set by editing the MonetDB.conf file (see MonetDB.conf) file, or at Mserver startup using the --set var=value command line switch.

Changing mapi_port will change de XRPC server port as well. The xrpc_port can be also set explicitly and this will not affect the value of mapi_port.

MonetDB/XQuery provides a standard place for putting XQuery Modules that are callable from outside: <datadir>/MonetDB/xrpc/export. Here datadir> is defined in the MonetDB.conf configuration file (see see MonetDB.conf).

Note that <datadir>/MonetDB/xrpc/ is the root of the directory served out by the HTTP server, so all XQuery module files in the export/ directory are served out as well (and can be referred to as URIs in XQuery qeries).

Trusted Modules.

For security reasons, the XRPC server will not execute an arbitrary module, instead, it will only execute those modules which location (given by the at-hint) has the same prefix as one of the values listed in the MIL variable xrpc_trusted. This xrpc_trusted variable contains semi-colon separated list of URI prefixes that are to be trusted, and can be set by by editing the MonetDB.conf file (see MonetDB.conf).

By default, only modules stored in the MonetDB domain and in the export directory can be called. Calls to functions in un-trusted modules will be rejected with an HTTP response code 403.

Setting the value of xrpc_trsuted to be empty means that all module URIs will be trusted.

File Serving. The XRPC server is a simple HTTP server as well. It serves all files stored in:

${prefix}/share/MonetDB/xrpc

For example, the dummy XQuery module "export.xq" that is standard installed in:

${prefix}/share/MonetDB/xrpc/export

can be retrieved using the URL:

http://<yourhost>:<xrpc_port>/export/export.xq

Directory listing is turned off and it can only be turned on by changing the XRPC source code.