hensm/fx_cast

"Bridge not found" after install on Arch, presumably caused by an invalid /opt/fx_cast/fx_cast_bridge binary

s1gtrap opened this issue · 5 comments

OS version: Arch Linux (6.8.1-arch1-1)
Browser version: 124.0.1
Extension version: Both 0.3.0 and 0.3.1
Bridge version: 0.3.0

Description
I'm getting the dreaded "Bridge not found" error after installing from AUR as directed, and I'm fairly certain it's because the bridge daemon isn't running (despite following all of the steps). Seemingly it's because the installed binary is invalid, but I simply have no idea how this is resolved..

Steps to reproduce

  1. Install fx_cast-bin (yay -S fx_cast-bin)
  2. Enable Avahi daemon (sudo systemctl enable avahi-daemon && sudo systemctl start avahi-daemon)
    • I even followed the steps to enable local hostname resolution by installing nss-mdns and editing /etc/nsswitch.conf
  3. Tried adding /etc/systemd/system/fx_cast.service as described in https://github.com/hensm/fx_cast/wiki/daemon

Expected behaviour
Bridge should be running and be reachable by Firefox.

Logs

After adding and enabling/starting the systemd daemon:

$ sudo systemctl status fx_cast
× fx_cast.service - fx_cast daemon
     Loaded: loaded (/etc/systemd/system/fx_cast.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Tue 2024-03-26 18:35:15 CET; 11min ago
   Duration: 654ms
   Main PID: 774 (code=exited, status=1/FAILURE)
        CPU: 19ms

Mar 26 18:35:15 toy systemd[1]: fx_cast.service: Scheduled restart job, restart counter is at 5.
Mar 26 18:35:15 toy systemd[1]: fx_cast.service: Start request repeated too quickly.
Mar 26 18:35:15 toy systemd[1]: fx_cast.service: Failed with result 'exit-code'.
Mar 26 18:35:15 toy systemd[1]: Failed to start fx_cast daemon.

which got me examining the files actually installed:

/opt/fx_cast/fx_cast_bridge -d
Pkg: Error reading from file.

which is really strange to me, as

file /opt/fx_cast/fx_cast_bridge 
/opt/fx_cast/fx_cast_bridge: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=9bf6eb717fdcfe8b55a39cb6dd64f4496619793d, for GNU/Linux 2.6.32, stripped

It's not because of the runtime environment either, as

$ node --version
v21.7.1
$ /opt/fx_cast/fx_cast_bridge -d   
Pkg: Error reading from file.
$ source /usr/share/nvm/init-nvm.sh
$ node --version
v16.20.2
$ /opt/fx_cast/fx_cast_bridge -d   
Pkg: Error reading from file.

For the record I also tried fx_cast but that one fails to install:

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                                                                               [################################################################] 100%
(1/1) checking package integrity                                                                             [################################################################] 100%
(1/1) loading package files                                                                                  [################################################################] 100%
(1/1) checking for file conflicts                                                                            [################################################################] 100%
(1/1) checking available disk space                                                                          [################################################################] 100%
:: Processing package changes...
(1/1) installing fx_cast                                                                                     [################################################################] 100%
/tmp/alpm_QX3P5b/.INSTALL: line 5: unexpected EOF while looking for matching `"'
/usr/bin/bash: line 1: post_install: command not found
error: command failed to execute correctly
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...

and I couldn't figure out how to edit the broken .install file as my changes never made effect.

It looks like a runtime issue of some kind. The version of Node.js used is bundled with the executable (using Pkg, as the message indicates), so the system version doesn't matter.

I don't use or maintain/support the AUR packages, but the bridge was working on Ubuntu and Fedora last time I tested it and nothing has changed for a while. I can only recommend building from source if the AUR package isn't working. You can build an unpackaged version (build script flags are documented in the README) which uses the system Node.js and will give some more insight into what's going wrong if there's still an issue.

Side note: unless you're using Firefox in a container, you probably don't want to use the daemon since Firefox is able to detect and launch the bridge directly.

Hey! Really appreciate the quick response!

I had tried building it myself prior, and despite successfully building fx_cast_bridge, I had no luck getting it to work with Firefox.

I did as instructed:

$ nvm install 16 
$ npm install
$ npm run build

which leaves me with

$ ls dist/bridge/
config.json  fx_cast_bridge.json  fx_cast_bridge.sh  src

running the generated executable gets me the following:

dist/bridge/fx_cast_bridge.sh                                       
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>

which I assume is intended?

But still fails with "Bridge not found", so I figured I had to install it, which I figured I could do with debtap:

$ npm run package
$ ls dist/bridge/
fx_cast_bridge-0.3.0-x64.deb
$ debtap dist/bridge/fx_cast_bridge-0.3.0-x64.deb
$ ls dist/bridge/                                 
fx-cast-bridge-0.3.0-1-x86_64.pkg.tar.zst  fx_cast_bridge-0.3.0-x64.deb
$ sudo pacman -U dist/bridge/fx-cast-bridge-0.3.0-1-x86_64.pkg.tar.zst
$ ls /opt/fx_cast
dns_sd_bindings.node  fx_cast_bridge

which seems to install it correctly, but the extension still fails with "Bridge not found"..

Even if I run it after install:

/opt/fx_cast/fx_cast_bridge 
*** WARNING *** The program 'fx_cast_bridge' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
*** WARNING *** The program 'fx_cast_bridge' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>

In either case it doesn't help to toggle the "Enable backup daemon" option, though I'm not sure if those are related.

So yea I'm still not sure of what else to do, hope that helps.

The bridge does at least appear to be functioning in some way.
You can safely ignore the Avahi warning.

It looks like there's something wrong with the native messaging manifest file (either it doesn't exist, it's in the wrong place, or it's broken in some way).

Check these paths:

~/.mozilla/native-messaging-hosts/fx_cast_bridge.json

/usr/(lib|lib64)/mozilla/native-messaging-hosts/fx_cast_bridge.json

If you used the install-manifest script when following the build instructions, it would have copied a manifest to the user directory that pointed to the location of the launch script. That would then override any system-level manifests.

If you can't get native messaging to work, try the daemon again, but you can't just run the executable, you need to pass the -d flag (the wiki page you've already seen has more info) or it'll be in native messaging mode. The backup daemon connection option then needs to be enabled.

Edit:
I'd definitely recommend the debtap method you used over running it unpackaged just because it's less fragile. The unpackaged version is really just for development and it'll break if files are moved around or Node.js changes.

Also, it's possible the issue is on the Firefox side, so logs could be helpful here:
https://github.com/hensm/fx_cast/blob/master/CONTRIBUTING.md#bug-reports

I figured out the root cause, for some reason makepkg isn't honoring options=('!strip') and is stripping the fx_cast_bridge binary, forcefully replacing the binary from the dist directory fixes the issue and allows the bridge to function properly.

This is a bug with makepkg not fx_cast.

I figured out the root cause, for some reason makepkg isn't honoring options=('!strip') and is stripping the fx_cast_bridge binary, forcefully replacing the binary from the dist directory fixes the issue and allows the bridge to function properly.

This is a bug with makepkg not fx_cast.

Is there a tracking issue for this? I definitely lost track of what I was doing somewhere along the line, and would definitely prefer not to work around bugs in necessary build tools..