Message Router Demo

Here is a demo of the first (very simple) version of the message router.

This assumes you have a working ocaml/opam/dune setup. Hit me up (or @nemael or @arie perhaps) if you don’t have this … the 3 of us use a Debian-based system and it’s fairly straightforward.

I’m using OCaml v.4.11.0

opam update

cd /your/sources/dir
git clone git@gitlab.com:public.dream/libs/ocaml-seaboar
cd ocaml-seaboar
opam install --with-test .

cd /your/sources/dir
git clone git@gitlab.com:public.dream/upsycle/message-router
cd message-router
git reset --hard fd3c8ac1c44db08d2dd182a6278fe28273b293c2
git submodule update --init --recursive
opam install --deps-only .
dune build
# --- this will generate certificates and store them in a .gitignore'd directory -- these shouldn't be checked in to git
bin/gen-certs

If you happen to have services running on :6000, :6001, or :7000 on your machine, change the values in conf/config-*.yaml

Run the demo executable:

bin/run-msg-router

The message router contains a state which currently simply stores the number of messages processed and the routing table. Press S to see the state. It starts with two fake routes; see conf/config-message-router.yaml

Press ‘m’ to simulate a message being received. This is a so-called ‘listen message’ (now obsolete I think), which services send to the message router to announce themselves. It consists of a simple header and a body containing the routing information of the service. It is encoded as CBOR and encoded/decoded using our CBOR library. Each one contains a random pubkey and a random IPv4 address and port.

Press S to see the state.

Press s to serialise the state to a file as CBOR (default: /tmp/upsycle-state.cbor). This will be necessary later if the message router is restarted. This also uses our CBOR library.

Press n to simulate a message which uses the pubkey of the first entry in the routing table (sorted alphanumerically) and a new route: this simulates an existing service announcing that it’s changing its routing information.

Press m to send some more messages, heck, press M to send 1000 messages at a time.

Press r to restore the state to its former version. There should be just one message processed and 3 routes.

In a separate terminal (don’t try to background the process using Ctrl-Z – this won’t work because reasons), run bin/run-service 1. This will a run mock service (think of this as one of the other unikernels, e.g. dmc or one of the pub-sub services), and register itself with the message router over TLS. You should see a new route in the routing table of the message router. The message router will also send a message back to the service through the newly established route over TLS: ‘hi there’.

You can also run a second service using bin/run-service 2

2 Likes

Testing on Debian 10, I have this issue installing opam dependencies on the second repository:

git submodule update --init --recursive
Submodule 'libs/alleycat-bash' (https://gitlab.com/alleycatcc/alleycat-bash) registered for path 'libs/alleycat-bash'
Cloning into '/home/how/src/dream/message-router/libs/alleycat-bash'...
warning: redirecting to https://gitlab.com/alleycatcc/alleycat-bash.git/
Submodule path 'libs/alleycat-bash': checked out '71cff4ebba15fe2f2b9483b1430b62bf35cbd100'
Sorry, no solution found: there seems to be a problem with your request.

No solution found, exiting

The ‘Sorry’ lines are output of opam install --deps-only .

PWD is /home/how/src/dream/message-router/message-router, I cloned in the ..

I must be missing some OCaml code.

Could you try:

opam update

I’ll add it to the instructions. Hopefully that’ll help.

Excited to try this. I had to upgrade from OCaml v.4.9.0 to v.4.11.0,
and install some additional dependencies, but I got everything to build.

I get an error from ./bin/run-msg-router:

٭ [ chdir ] /home/person/projects/DREAM/repos/message-router/bin/../message-router
٭ go ()
٭ dune exec -- bin/message_router.exe --config /home/person/projects/DREAM/repos/message-router/bin/../conf/config-message-router.yaml
[server -> 127.0.0.1:7000] starting
message_router: internal error, uncaught exception:
                (Failure "No SSL or TLS support compiled into Conduit")
                
* bye.

Allen Haim via DREAM transcribed 12K bytes:

Aha. Probably missing system libraries for libssl / libssl-dev.

On Debian-like systems: sudo apt install libssl-dev

Time for nix / guix perhaps eh

And then for good measure, you might need:

opam reinstall conduit-lwt-unix=2.2.2

From the internet (untested):

opam install lwt_ssl

Edit: tls and lwt_ssl are ‘depopts’ of conduit-lwt-unix. So perhaps:

opam install lwt_ssl tls

Edit: after some more experimentation it seems you need at least one of lwt_ssl or tls. Having both is fine too. I don’t know which is better.

i’ll make a nix flake for it

1 Like

bravo! quite impressed I will ask for a personal demo to @Nemael

1 Like

opam install lwt_ssl tls

that was the key. i already had libssl-dev installed.

done. you can try running it in nix develop or nix-shell

opam install --deps-only --with-test . still fails with the latest revision. I’m waiting for lwt_ssl to install. (Low-bandwidth unpower) – shouldn’t this package be part of the dependencies?


lwt_ssl successfully installed. On Debian, it required the pkg-config package to complete.

Edited with updated URL.

Yes you’re right. We need to add either lwt_ssl or tls to the .opam file.

I started over…

At this point I get:

( how )% opam install --deps-only .
[WARNING] No package definitions found at /home/how/src/dream/message-router/message-router
Nothing to do
( git repo )--[ message-router ⑂master@cda4e14 ]--()master

??? Maybe the OCaml version is insufficient… But it’s Debian Stable, so I expect it should work.

( how )% ocaml --version
The OCaml toplevel, version 4.05.0

Sorry, dir structure has changed in the meantime.

Adding a specific revision and updating instructions.

1 Like

You’ll probably need a more recent OCaml as wel. It’s known to work on 4.11.0, and @dvn reported needing to upgrade even from 4.9.0.

Ack, 4.11 is in Debian Testing so it’s fine.

I will try using Guix. Guix has 4.09.0 unfortunately.

Recommendation for setting up OCaml in Debian: remove all OCaml-related packages except opam and opam-installer.

Then

opam init
opam switch create <your-compiler-version>
# --- e.g.:
# opam switch create 4.12.0
opam switch
# --- you should see a 'switch' named '4.12.0' and the compiler 'ocaml-base-compiler.4.12.0'
opam install dune
# --- install everything else through opam
# opam install package [...package]
1 Like

Thank you for the updated instructions @misterfish!

I was expecting the process to go through all the way but

gives:

bin/run-msg-router
٭ [ chdir ] /home/how/src/dream/message-router/bin/../message-router
٭ go ()
٭ dune exec -- bin/message_router.exe --config /home/how/src/dream/message-router/bin/../conf/config-message-router.yaml
Entering directory '/home/how/src/dream/message-router'
Entering directory '/home/how/src/dream/message-router'
[server -> 127.0.0.1:7000] starting
message_router: internal error, uncaught exception:
                (Failure "No SSL or TLS support compiled into Conduit")

After installing lwt_ssl, it worked. I imagine that you need to figure one of dependencies on either lwt_ssl or tls packages and this might not be trivial. Is there an issue open for that?

Then I proceeded to run the demo (successfully this time!). Looking at the routing table, I assume the IP addresses are generated at random.

Running the service gives:

( how )% bin/run-service 1
٭ [ chdir ] /home/how/src/dream/message-router/bin/../message-router
٭ go (1)
٭ dune exec -- bin/test_service.exe --config /home/how/src/dream/message-router/bin/../conf/config-test-service-1.yaml
Entering directory '/home/how/src/dream/message-router'
Entering directory '/home/how/src/dream/message-router'
~ registering with message router
~ starting server
[server -> 127.0.0.1:6000] starting
test_service: internal error, uncaught exception:
              (Failure
                "Unable to register with message router: SSL connection() error: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed")

I have nothing running on port 6000 AFAIK. Trying with port 6666 and fails too.

Note: if there’s a bug, it will hit me :woozy_face:

What do you need from me to help debug?