opencog / cogserver

Distributed AtomSpace Network Server
Other
15 stars 22 forks source link
atomspace network opencog server

OpenCog CogServer

CircleCI

The OpenCog CogServer is a network scheme & python command-line server for the OpenCog AtomSpace (hyper-)graph database. It allows network users to run arbitrary python and scheme code on the server, and access the AtomSpace over the network. The cogserver also provides a pseudo-JSON interface, as well as a high-speed data transfer format that is used for building network-distributed AtomSpaces. The CogServer is a part of the OpenCog project.

Overview

The CogServer provides a network command-line console and a WebSocket server. The network console server provides a fast, efficient telnet interface, giving access to Scheme (guile), Python and JSON command-lines. These can be used by multiple users at the same time, all obtaining access to the same AtomSpace. This is also shared by the WebSocket interface, so that all users see the same data, irrespective of the network connection.

This capability is useful in several different ways:

For more info, please consult the CogServer wiki page.

Version

This is version 3.2.0. The code is stable, it's been used in production settings for a decade. There are no known bugs. There are some planned features; see below.

Using

There are three ways to start the cogserver: from a bash shell prompt (as a stand-alone process), from the guile command line, or from the python command line.

Once started, one can obtain a shell by saying rlwrap telnet localhost 17001, and then py, scm or json to obtain python, scheme or json shells. This can be done as many times as desired; all shells share the same AtomSpace, and the system is fully multi-threaded/thread-safe. The status of all network connections is displayed by stats. For more info, type help py, help scm, help json and help stats.

The rlwrap utility simply adds arrow-key support, so that up-arrow provides a command history, and left-right arrow allows in-place editing. Note that telnet does not provide any password protection! It is fully networked, so you can telnet from other hosts. The default port number 17001 can be changed; see the documentation.

The socket protocol used is 'trivial'. Thus, besides telnet, one can also use netcat, or access the socket directly, with ordinary socket connect, open and read/write calls.

WebSocket programmers will find it convenient to use their own favorite tools to access the json API. A very simple example can be found in the WebSocket Example directory.

Building and Running

The CogServer is built exactly the same way that all other OpenCog components are built:

clone https://github.com/opencog/cogserver
cd cogserver
mkdir build
cd build
cmake ..
make -j

For additional information on dependencies and general hand-holding with the build, see the building Opencog wiki.

Prerequisites

To build and run the CogServer, you need to install the AtomSpace first.

AtomSpace

OpenCog AtomSpace database http://github.com/opencog/atomspace It uses exactly the same build procedure as this package. Be sure to sudo make install at the end.

The WebSockets server needs the OpenSSL devel environment to be installed.

OpenSSL

OpenSSL On Debian/Ubuntu, sudo apt install libssl-dev

Unit tests

To build and run the unit tests, just say

    make test

from the ./build directory.

Architecture

See also these README's:

TODO

There are two major open ToDo items for the CogServer. These are:

It's not clear how to introduce security into this model, other than to only open network connections to trusted, authorized users. Presumably, there are several off-the-shelf solutions for controlling network access, but no one has picked a good one. Obviously, exporting the CogServer socket via SSH is a good way of controlling access to who can use it. But SSH proxying is very low-level, and not admin-friendly. Nor particularly user-friendly, either: the user can't just login into some website and ask for access.