Genie Community Forum

Local deployment of almond-server "Lost connection to the server."

I’m running a local deployment of almond-server using docker (using latest-portable since I’m not interested in audio capture). The server starts correctly, but after setting up the password I can’t actually use it because, on the conversation tab I see the “Lost connection to the server.” warning.

Debugging a little bit I realized that the websocket connection to /conversation is getting closed as soon as it’s getting opened.

I don’t know if this is related, but I also got the same error in https://almond.stanford.edu until I created an account.

Hi @carlos5678, welcome to the forum!

How did you set up your docker container, that is, what networking? Do you have a proxy in front?
The problem might be the Origin check, if the connection appears to be coming to the server from a remote client, but the browser thinks it’s connecting to localhost.

Docker container is connected to an internal docker network that is fronted by NGINX as a reverse proxy.

This is my ansible configuration for the container, syntax is different from docker-compose, but I think it’s pretty straightforward

    - name: Setup almond
      docker_container:
        name: almond
        image: stanfordoval/almond-server:latest-portable
        state: started
        restart_policy: unless-stopped
        networks:
          - name: nginx_network
        volumes:
          - "/nas-main-vol/confs/home/almond:/var/lib/almond-server"

If I connect directly to the almond instance without going through NGINX it does work. How can I configure it to support the proxying from NGINX?

To use NGINX as reverse proxy, you can either:

  • set up NGINX to perform authentication, then disable almond-server’s internal authentication, by setting THINGENGINE_HOST_BASED_AUTHENTICATION=insecure
  • set up NGINX to check the Origin header (which should match the hostname you’ll use through the browser), and then override the header to the same protocol://ip:port that nginx uses to talk to Almond

https://github.com/stanford-oval/almond-server/issues/37 has some additional discussion of different configuration options.

Thanks for the help @gcampax

I Added the env var THINGENGINE_HOST_BASED_AUTHENTICATION=insecure to the docker configuration and although Almond no longer asks for a password, the conversation panel still says "Lost connection to the server.” :frowning:

Checked and the websocket is still being disconnected.

You probably still needs to set the Origin header.

Your setup is very similar to that used by official Home Assistant addon, which also has a nginx load-balancer. So you can probably use a similar configuration as