Blog

VerneMQ: econnrefused & Webhook example

Webhooksactivate webhooks like this in your vernemq.conf.local (.local when running on docker, so that settings at bottom of the file will persist):plugins.vmq_webhooks = onvmq_webhooks.js_auth_on_register.hook = auth_on_register vmq_webhooks.js_auth_on_register.endpoint = http://container_picockpit:1200/example/pathNote that if your webhook is not accessible (econnrefused), the db based authentication will also fail … ! If you get errors like the following:jalpine_morpheus | 17:11:10.394 [...]

By | Mai 20th, 2019|VerneMQ|Kommentare deaktiviert für VerneMQ: econnrefused & Webhook example

envoy serving a static response

Besides routing and redirecting you can serve static responses with Envoy.In this case I want to serve a forbidden response (403)route_config:   virtual_hosts:   - name: picockpit     domains: ["picockpit.local:443", "picockpit.local"]     routes:       - match: { prefix: "/demo" }         direct_response:           status: 403           body:             inline_string: "Forbidden."        - match: {prefix: "/"}         route: {cluster: target_picockpit}It can also serve up files from [...]

By | Mai 20th, 2019|Development|Kommentare deaktiviert für envoy serving a static response

Python Paho MQTT client self-signed certificates websockets, howto

Using Paho in Python with websockets and self-signed certificates for a https:// websocket connection has a couple of pitfalls, so I’m addressing this with some sample code here:import ssl import time import paho.mqtt.client as mqtt class PCPMQTTClient:     def on_connect(self, client, userdata, flags, rc):         self.connection_status = rc         if rc == 0:             self.connected_flag = True             self.connection_error_flag = [...]

By | Mai 19th, 2019|Development, Python|Kommentare deaktiviert für Python Paho MQTT client self-signed certificates websockets, howto

VerneMQ Docker overwrites my configuration

SituationYou edit vernemq.conf, only to find that your configuration is overwritten by VerneMQ on the next start (using the official Docker container).Specifically, the section with the listeners at the end of the file is “forced upon you”.SolutionVerneMQ is started using a script (start_vernemq). The script can be seen here:https://github.com/vernemq/docker-vernemq/blob/master/bin/vernemq.shThe important part is here:As you see, [...]

By | Mai 19th, 2019|Development, VerneMQ|Kommentare deaktiviert für VerneMQ Docker overwrites my configuration

envoy not connecting to VerneMQ for MQTT over websockets, error code 503

Some quick background information for anyone running into the same issues, and how to debug them.Error code 503This is the error code I am getting:Error during WebSocket handshake: Unexpected response code: 503.Set envoy logging to debugHere’s my docker-compose.yaml for envoy:version: '3.7' services:   envoy:     build:       context: ./       dockerfile: Dockerfile     container_name: penvoyage-morpheus-envoy     ports:       - "80:1080"       - "443:1443"     [...]

By | Mai 19th, 2019|Development|Kommentare deaktiviert für envoy not connecting to VerneMQ for MQTT over websockets, error code 503

envoy websockets per route configuration, JavaScript test setup

In my article yesterday I discussed the configuration & test of envoy for proxying websockets at length.Today I would like to add some additional information.correct syntax for websocket upgrade per routeYou can enable websocket upgrade per route. No need to add it globally:- name: envoy.http_connection_manager    config:      #upgrade_configs:      #  - upgrade_type: websocket      stat_prefix: ingress_https      use_remote_address: true      [...]

By | Mai 19th, 2019|Development|Kommentare deaktiviert für envoy websockets per route configuration, JavaScript test setup

envoy, docker and websockets – debugging and configuration

Websockets are an exciting technology, allowing you to upgrade a HTTP connection to a long-running persistent binary connection, which you can use to send bi-directional messages.As an aside, the MQTT protocol can be transported using websockets – which is the only (?) way for a JavaScript client delivered by the website, for instance.In any case, [...]

By | Mai 18th, 2019|Development, Docker|Kommentare deaktiviert für envoy, docker and websockets – debugging and configuration

correct way to instantiate Paho Client in JavaScript for wss (secure websocket)

The Paho documentation is unfortunately quite fragmented at the moment, and some links on Eclipse’s website do not work.Here are some working links (as of 05/2019):https://www.eclipse.org/paho/clients/js/https://www.eclipse.org/paho/files/jsdoc/index.htmlhttps://github.com/eclipse/paho.mqtt.javascriptAnd here’s a fantastic website by Steve:http://www.steves-internet-guide.com/using-javascript-mqtt-client-websockets/There is an important breaking change in the Paho namespace, where you will run into trouble using Steve’s code:“Previously the Client's Namepsace was Paho.MQTT, [...]

By | Mai 17th, 2019|Development|Kommentare deaktiviert für correct way to instantiate Paho Client in JavaScript for wss (secure websocket)

Understanding Erlang & Lua / Luerl for VerneMQ MongoDB auth_on_register hook

My goal / TLDRMy goal with this blog post is to explain how to set custom mountpoints for VerneMQ by modifying the shipped MongoDB auth Lua script  (lua/auth/mongodb.lua).Setting a custom mountpoint is possible with VerneMQ not only by setting mountpoints manually for specific listeners (e.g. ports), but also programmatically during authorization in your scripts.I had [...]

By | Mai 12th, 2019|Development|Kommentare deaktiviert für Understanding Erlang & Lua / Luerl for VerneMQ MongoDB auth_on_register hook

mongo_orm Exception: missing bson key: publish_acl (Exception)

When you extend your field definitions in the mongo_orm document classes, specifically with embedded documents, you might run into the following runtime (!) error:Exception: missing bson key: <name> (Exception)This is not an error in your code – your code is raising, because the database structure is not as it expects it to be!Here’s the sample [...]

By | Mai 10th, 2019|Crystal Language|Kommentare deaktiviert für mongo_orm Exception: missing bson key: publish_acl (Exception)