Redis <> AI2


We have had the cloudDB component for some time now, which uses a redis server as the database backend. It has also been possible for developers to use their own redis server, including SSL, with the cloudDB component. I can now provide a method that offers developers direct access to a Redis server, so that all the features offered by Redis can be used in an AI2 app.  This is achieved by using the Webdis "front end" to Redis, an http server that sends commands and receives output from Redis. It is then possible to use http calls in the extension to send and return information to Webdis, then to redis and back again. Given that I already have a redis server setup, I have used this for simplicity. My Redis version is only 5.07, this has no built in features for SSL, therefore Webdis commands are sent using HTTP and not HTTPS for this guide. It should be possible to set everything up using SSL with Redis version < 6.0


You will require:

Ubuntu Server & Redis

I am not going to try and reinvent the wheel here. Digital Ocean provide some useful howto guides on setting up a server and installing and setting up Redis

Server Setup Guide

You will need to make some changes to your firewall, allowing all access to ports: 6379, 7379. 

Redis Setup Guide

Digital Ocean also provide a group of guides about how Redis works and its features

Redis Usage Guides

There are other host providers.....

You should, as a minimum, set a strong password (or user/password depending on Redis version) for your redis instance in the config file.

The Redis Command Reference Pages will also assist with understanding the workings of Redis


You should have a very good read of everything here: Webdis on Github

If you have git setup on your server, you can clone Webdis, otherwise, download the zip, unzip it, then upload the webdis-master folder to your sudo user's home directory.

Ensure you have libevent-dev installed:

sudo apt-get install libevent-dev

You will also need make and gcc installed to build from sources

cd into the webdis-master directory and run make clean all

We now need to setup the webdis.json file (config file):


  "redis_host": "",

  "redis_port": 6379,

  "redis_auth": "abc123xyz456",

  "http_host": "12.34.567.890",

  "http_port": 7379,

  "threads": 5,

  "pool_size": 20,

  "daemonize": false,

  "websockets": false,

  "database": 0,

  "acl": [

    {"disabled": ["DEBUG"]},    

    {"http_basic_auth": "user1:pass1", "enabled": ["*"]}


  "verbosity": 4,

  "logfile": "webdis.log"


The three "key":"values" of interest here are "redis_auth", "http_host", and "acl".

We can now start Webdis. Still in the directory webdis-master run the following: ./webdis &

That should start Webdis, and we are now ready to test the webdis/redis functionality. You will see that you can daemonize Webdis in the config file.

From your computer, open a terminal and try the following curl command, using your own IP address and user/pass:

curl -u user1:pass1 -vs https://12.34.567.890:7379/PING

this should return:


If it does you are good to go, if not, then you will need to go over your work to see what you have missed, and also check your firewall.

App Inventor


The RedisConnector extension has been built to provide easy access to the most useful commands in Redis, and simplifies the uploading and downloading of binary files to/from the server. The inclusion of AppId/ProjectId/Database further assists in the separation of an ai2 project from anything else going on on the redis server. All keys will include the AppId and ProjectId, but these will be "hidden" in sends and output returns. Similarly, the setting of the database (there are 16 databases or namespaces, 0-15, which can be used) also provides a degree of separation from other activities on the server.  The default database is 0.

The RedisConnectorExpert extension does away with all the above, and provides only a single block for the entry of commands (as well as the file upload/download blocks) and provides the developer with free rein over how the app is used.