Wifi-Connect sends out wifi but the webpage doesn't show up

Wifi-Connect sends out wifi but the webpage doesn’t show up

So I was able to create an application with Balena wifi-connect and it compiled and was uploaded to balenaOS fine. The device, as raspberry pi B+ installed the application fine and I can see “Wifi-Connect” in my available networks but once selected, it doesn’t actually do anything. Meaning it doesn’t start the web page for you to actually select an SSID and password. Any idea what this could be?

My docker compose is:

version: '2'
services:
  wifi-connect:
    build: ./wifi-connect
    expose:
      - "80"
    labels:
      io.resin.features.dbus: '1'
  wpe:
    build: ./wpe

The dockertemplate file inside of wifi-connect is:

FROM balenalib/%%RESIN_MACHINE_NAME%%-debian

RUN install_packages dnsmasq wireless-tools

WORKDIR /usr/src/app

RUN curl https://api.github.com/repos/balena-io/wifi-connect/releases/latest -s \
    | grep -hoP 'browser_download_url": "\K.*%%RESIN_ARCH%%\.tar\.gz' \
    | xargs -n1 curl -Ls \
    | tar -xvz -C /usr/src/app/

COPY scripts/start.sh .

CMD ["bash", "start.sh"]

Hi @kingstonsteele it sounds like the wifi chip might not properly support AP mode. Can you give us a bit more info on what wifi module you are using?

Hi @KingstonSteele,

You need to add a couple of more settings to your docker-compose file:


  wifi-connect:
    build: ./wifi-connect
    network_mode: "host"
    privileged: true
    labels:
      io.resin.features.dbus: '1'

I do not think you need to expose port 80 (unless the wpe container accesses it).

It’s a rapsberry pi 3b + and works when I just download a project like balenadash or something but as soon as I try and customize any ui (change logos) it doesn’t want to display the page.

I tried using the code found here:

FROM balenalib/%%BALENA_MACHINE_NAME%%-ubuntu:latest

RUN sudo apt-get -y update && \
    sudo apt-get -y install bluez build-essential cmake git libglib2.0-dev dnsmasq network-manager openjdk-8-jdk pkg-config sqlite3 wireless-tools && \
    sudo apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-arm64
ENV DBUS_SYSTEM_BUS_ADDRESS unix:path=/host/run/dbus/system_bus_socket

WORKDIR /usr/src/wifi-connect
RUN curl https://api.github.com/repos/balena-io/wifi-connect/releases/latest -s \
    | grep -hoP 'browser_download_url": "\K.*%%BALENA_ARCH%%\.tar\.gz' \
    | xargs -n1 curl -Ls \
    | tar -xvz -C /usr/src/wifi-connect/

WORKDIR /usr/src/wifi-connect/

COPY ./start.sh ./
CMD ./start.sh

As outlined here: Wifi Connect not displaying login credentials page on Raspberry Pi 3B+

But alas, the wifi credentials do not show up. I also found this link: https://github.com/balena-io/wifi-connect/issues/164

which suggests changing the WORKDIR in docker.template. Thoughts?

I’ve noticed you install network-manager in the container. That should not be done as the NetworkManager service is already running in the host OS. Quite possibly this breaks it.

If it is not the source of the problem, can you please provide more details about how you try to customize the UI?

When the WiFi Connect archive is extracted in the container it includes the wifi-connect binary and the ui folder. You may modify it according to your needs indeed.

Does the application works without any modifications on top of the ui folder?

As it sits right now this is what I’ve got:

dockercompose.yml

Located in /projectfolder
Inside the /projectfolder are these files

CHANGELOG.md		README.md		docker-compose.yml	
CONTRIBUTING.md		VERSION			wpe-browser
FAQ.md			accelerometer		repo.yml    wifi-connect

dockercompose.yml looks like this:

version: '2'
services:
  wpe-browser:
    restart: always
    build: ./wpe-browser
    ports:
      - 8080:8080
  wifi-connect:
    build: ./wifi-connect
    restart: always
    network_mode: host
    privileged: true
    labels:
      io.balena.features.dbus: '1'
      io.balena.features.firmware: '1'

dockerfile.template

located inside of /projectfolder/wifi-connect
Inside the /projectfolder are these files:

CHANGELOG.md		LICENSE			rustfmt.toml		ui
Cargo.lock		ManualTests.md		scripts			versionist.conf.js
Cargo.toml		README.md		src
Dockerfile.template	package-lock.json	start.sh

The dockerfile.template looks like this:

FROM balenalib/%%BALENA_MACHINE_NAME%%-ubuntu:latest

RUN sudo apt-get -y update && \
    sudo apt-get -y install bluez build-essential cmake git libglib2.0-dev dnsmasq openjdk-8-jdk pkg-config sqlite3 wireless-tools && \
    sudo apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-arm64

WORKDIR /usr/src/wifi-connect
RUN curl https://api.github.com/repos/balena-io/wifi-connect/releases/latest -s \
    | grep -hoP 'browser_download_url": "\K.*%%BALENA_ARCH%%\.tar\.gz' \
    | xargs -n1 curl -Ls \
    | tar -xvz -C /usr/src/wifi-connect/

WORKDIR /usr/src/wifi-connect/

COPY ./start.sh ./
CMD ./start.sh

I tried omitting the network-manager line, however the problem was not solved and I received a new error saying nmcli: command not found. This goes away if I change:
# 2. Is there Internet connectivity? #nmcli -t g | grep full

back to

# 3. Is there Internet connectivity via a google ping? wget --spider http://google.com 2>&1

Inside the start.sh file. This makes me think maybe the container isn’t accessing network-manager since nmcli is part of the network-manager package.

start.sh

Also located in /projectfolder/wifi-connect looks like this:

#!/usr/bin/env bash

export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket

sleep 10
while [[ true ]]; do
  # Choose a condition for running WiFi Connect according to your use case:

  # 1. Is there a default gateway?
  # ip route | grep default

  # 2. Is there Internet connectivity?
  #nmcli -t g | grep full

  # 3. Is there Internet connectivity via a google ping?
  wget --spider http://google.com 2>&1

  # 4. Is there an active WiFi connection?
  # iwgetid -r

  if [ $? -eq 0 ]; then
      printf 'Skipping Wifil Connect\n'
  else
      printf 'Starting Wifi Connect\n'
      # UI directory, timeout, SSID, port
      ./wifi-connect -u /ui -a 600 -s SSID_NAME -o 80
  fi
  # wait 30 seconds before checking again for internet connectivity
  sleep 30
done

As for ui changes, even if I don’t make changes, or even exclude the -u option, it still doesn’t want to display the page, not when it’s inside the docker container. I can make it run by itself but even then cannot get -u option to work. Perhaps my syntax above and below is wrong:

./wifi-connect -u /ui -a 600 -s SSID_NAME -o 80

And as to what changes I’m trying to implement, they are simple logo changes made by replacing the files with another file of the same name.

This is all for a raspberry pi 3B+

Perhaps we can start from the top, with everything that would need to be done to get this to work. I’m finding bits and pieces online but nothing coherent.

Where do you keep your modified UI files? In the command you pasted you tell wifi-connect to look at the root /ui if you want to pass the path relative to the binary you should pass ./ui instead

1 Like

Hello, I just tried installing wifi-connect in the same way, everything worked.
Here is what I did step by step:

  • git submodule add git@github.com:balena-io-projects/balena-wpe.git
  • mkdir wifi-connect
  • created a wifi-connect/start.sh file containing
iwgetid -r

if [ $? -eq 0 ]; then
    printf 'Skipping WiFi Connect\n'
else
    printf 'Starting WiFi Connect\n'
    ./wifi-connect
fi

# Start your application here.
sleep infinity
  • created a wifi-connect/Dockerfile.template file containing
FROM balenalib/%%BALENA_MACHINE_NAME%%-ubuntu:latest

RUN sudo apt-get -y update && \
    sudo apt-get -y install dnsmasq wireless-tools && \
    sudo apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /usr/src/wifi-connect
RUN curl https://api.github.com/repos/balena-io/wifi-connect/releases/latest -s \
    | grep -hoP 'browser_download_url": "\K.*%%BALENA_ARCH%%\.tar\.gz' \
    | xargs -n1 curl -Ls \
    | tar -xvz -C /usr/src/wifi-connect/

WORKDIR /usr/src/wifi-connect/

COPY ./start.sh ./
CMD ["bash", "start.sh"]
  • created a docker-compose.yml file containing
version: '2'
services:
  balena-wpe:
    restart: always
    build: ./balena-wpe
    ports:
     - 8080:8080
  wifi-connect:
    build: ./wifi-connect
    restart: always
    network_mode: host
    privileged: true
    labels:
      io.balena.features.dbus: '1'
  • pushed everything to balena: balena push myApplicationName;
  • preloaded my rpi3 image: balena preload /path/to/dist/image;
  • flashed the disk image to an sd card;
  • put the sd card in the rpi3 and powered it on.

wifi-connect worked as expected.
If you want to change its ui, you’ll need to add some COPY instructions before CMD in wifi-connect/Dockerfile.template

This is my wifi-connect container. All ui is inside of the folder below called “ui”. The only thing I changed is heading text in the index.html

CHANGELOG.md		LICENSE			rustfmt.toml		ui
Cargo.lock		ManualTests.md		scripts			versionist.conf.js
Cargo.toml		README.md		src
Dockerfile.template	package-lock.json	start.sh

So it look like this:

projectName/wifi-connect/ui

How exactly should that look? Sorry for the noobness here.

Also should my -u option be ./ui or just /ui?

My file paths look like this: projectName/wifi-connect/ui

Hey @KingstonSteele did you try the suggestion in Wifi-Connect sends out wifi but the webpage doesn't show up to change your ./wifi-connect -u /ui -a 600 -s SSID_NAME -o 80 command to ./wifi-connect -u ./ui -a 600 -s SSID_NAME -o 80 or otherwise to the correct path for where you’re putting your ui folder

Yeah I did change that -u option from /ui to ./ui Still same issue. Wifi-Connect shows up as an available wifi network but nothing is actually displayed for the actual login page.

Not only that but I can’t connect it to my designated wifi and I have to reflash everytime I make a change so that I can get internet again.

I must be missing something in the dockerfile.template as @zvin mentioned.

Given where my ui file is located, what information in the dockerfile.template needs to go here:

COPY ./start.sh ./
CMD ./start.sh

Do you also COPY the files in, because I just realised that double-checking the Dockerfile’s you pasted there’s no COPY ui ... instruction so your ui files may not actually be in the container

I tried this to no avail:

COPY ./start.sh ./ui ./
CMD ./start.sh

Is that correct?

@kingstonsteele
So are you getting a 404 (or some different) response when you try to load the page or a connection problem?

No just that the page doesn’t even pop up. I even try localhost:80 and that doesn’t do anything. I can connect to wifi-connect but I can’t see the credentials page to login into wifi.

@kingstonsteele your COPY command is incorrect, please refer to the documentation.
COPY ./start.sh ./ui ./ will copy start.sh and all files inside ui into the container’s working directory, it is actually like COPY ./start.sh ./ui/* ./
You should split this line into:

COPY start.sh .
COPY ui ui

You can add a RUN ls line to check that the files are there.

I did get a custom UI working finally. Wifi-connect only shows up or runs once though. I added this line to my start.sh:

ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket

I then see this error in the terminal:

31.10.19 07:38:12 (-0700)  wifi-connect  Starting Wifi-Connect
31.10.19 07:38:12 (-0700)  wifi-connect  Cannot get the NetworkManager service state
31.10.19 07:38:12 (-0700)  wifi-connect  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: D-Bus error: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory (org.freedesktop.DBus.Error.FileNotFound)', /checkout/src/libcore/result.rs:906:4
31.10.19 07:38:12 (-0700)  wifi-connect  note: Run with `RUST_BACKTRACE=1` for a backtrace.

So somehow I’m not using the DBUS?

In my dockercompose I have:

version: '2'
services:

  wifi-connect:
    build: ./wifi-connect
    restart: always
    network_mode: host
    privileged: true
    labels:
      io.balena.features.dbus: '1'
      io.balena.features.firmware: '1'

My start.sh is:

#!/usr/bin/env bash


ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket

sleep 10
while [[ true ]]; do
  # Choose a condition for running WiFi Connect according to your use case:

  # 1. Is there a default gateway?
  # ip route | grep default

  # 2. Is there Internet connectivity?
  #nmcli -t g | grep full

  # 3. Is there Internet connectivity via a google ping?
  wget --spider http://google.com 2>&1

  # 4. Is there an active WiFi connection?
  # iwgetid -r

  if [ $? -eq 0 ]; then
      printf 'Skipping Wifi-Connect\n'
  else
      printf 'Starting Wifi-Connect\n'
      # UI directory, timeout, SSID, port
      ./wifi-connect -u ./ui -a 600 -s CUSTOMSSID-o 80
  fi
  # wait 30 seconds before checking again for internet connectivity
  sleep 10
done

I can get it work only once and that’s ONLY when I use option #4 above.

My dockerfile.template is:

FROM balenalib/%%BALENA_MACHINE_NAME%%-ubuntu:latest

RUN sudo apt-get -y update && \
    sudo apt-get -y install dnsmasq wireless-tools && \
    sudo apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /usr/src/wifi-connect
RUN curl https://api.github.com/repos/balena-io/wifi-connect/releases/latest -s \
    | grep -hoP 'browser_download_url": "\K.*%%BALENA_ARCH%%\.tar\.gz' \
    | xargs -n1 curl -Ls \
    | tar -xvz -C /usr/src/wifi-connect/

WORKDIR /usr/src/wifi-connect/

COPY start.sh ./
COPY ui ui
CMD ./start.sh

@KingstonSteele try moving the ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket you mentioned you added to your start.sh script to your Dockerfile instead, after the FROM line, like this:

FROM balenalib/%%BALENA_MACHINE_NAME%%-ubuntu:latest

ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket

RUN sudo apt-get -y update && \
    sudo apt-get -y install dnsmasq wireless-tools && \
    sudo apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /usr/src/wifi-connect
RUN curl https://api.github.com/repos/balena-io/wifi-connect/releases/latest -s \
    | grep -hoP 'browser_download_url": "\K.*%%BALENA_ARCH%%\.tar\.gz' \
    | xargs -n1 curl -Ls \
    | tar -xvz -C /usr/src/wifi-connect/

WORKDIR /usr/src/wifi-connect/

COPY start.sh ./
COPY ui ui
CMD ./start.sh
1 Like