brotab
brotab copied to clipboard
brotab doesn't work on ubuntu 22.04
Hey, I have upgrade my PC to Ubuntu 22.04 lately and I can't figure out why brotab isn't working.
bt
and the mediator
are communicating, I can see logs at /tmp/brotab_mediator.log
but it seems that it can't grab info from my firefox.
First I thought its something about firefox is installed by snap
in 22.04 so I installed as a .deb
instead but it didn't work.
I have installed the extensions I have ran bt install
and I ensured that the mediator json is actually there.
ofirg@ofirg:/tmp $ bt clients
ofirg@ofirg:/tmp $ bt windows
ofirg@ofirg:/tmp $ bt list
ofirg@ofirg:/tmp $
Firefox log
14:34:49.378 Detecting browser background.js:200:9
14:34:49.379 Connecting to native app background.js:208:11
14:34:49.382 It's Firefox: [object Object] background.js:211:13
14:34:49.382 Connected to native app brotab_mediator background.js:645:9
brotab_mediator.log
2022-07-03 14:04:58,125 19400 INFO main.py:143:list_tabs Listing tabs
2022-07-03 14:04:58,126 19400 INFO main.py:115:create_clients Created clients: []
Versions
ofirg@ofirg:/tmp $ firefox -V
Mozilla Firefox 102.0
ofirg@ofirg:/tmp $ python3 -V
Python 3.10.4
Mediator
ofirg@ofirg:/tmp $ cat /home/ofirg/.mozilla/native-messaging-hosts/brotab_mediator.json
{
"name": "brotab_mediator",
"description": "This mediator exposes interface over TCP to control browser's tabs",
"path": "/home/ofirg/.local/bin/bt_mediator",
"type": "stdio",
"allowed_extensions": [ "[email protected]" ]
}
How can I troubleshoot this any further?
Looks like bt
can't find open ports that mediator
is listening to. It tries to scan the range from 4625 to 4635 and it seems it can't find any. Try checking which port mediator
is actually listening to. e.g. in my setup:
$ sudo netstat -nplt | grep python | grep 46
tcp 0 0 127.0.0.1:4626 0.0.0.0:* LISTEN 1586875/python
tcp 0 0 127.0.0.1:4628 0.0.0.0:* LISTEN 1589848/python
$ curl 'http://localhost:4626/get_browser'
firefox
$ curl 'http://localhost:4628/get_browser'
chrome/chromium
Thanks for the quick reply. You are right there are no sockets listening from python.
ofirg@ofirg:~/dotfiles (master) $ sudo netstat -nplt | grep python
ofirg@ofirg:~/dotfiles (master) $
There are no mediator logs, it seems that the firefox didn't run the mediator, when I run the mediator manually I see the startup logs.
This console.log(port)
should sender
be undefined
13:23:27.313
Object { name: "brotab_mediator", sender: undefined, error: null, onMessage: {…}, onDisconnect: {…}, postMessage: (), disconnect: () }
Possibly due to Firefox being a snap by default in 22.04?
If so, probably related to #33.
As i said I installed firefox as .deb
Ah, obviously missed that. Sorry. :)
Any news about that @balta2ar ?
Sorry, I must have missed your reply.
When you do bt install
, it prints a bunch of paths, e.g.:
$ bt install
Installing mediator manifest /home/ybochkarev/.mozilla/native-messaging-hosts/brotab_mediator.json
Installing mediator manifest /home/ybochkarev/.config/chromium/NativeMessagingHosts/brotab_mediator.json
Installing mediator manifest /home/ybochkarev/.config/google-chrome/NativeMessagingHosts/brotab_mediator.json
Installing mediator manifest /home/ybochkarev/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts/brotab_mediator.json
Could you check what's in the file that corresponds Firefox?
$ cat /home/ybochkarev/.mozilla/native-messaging-hosts/brotab_mediator.json
{
"name": "brotab_mediator",
"description": "This mediator exposes interface over TCP to control browser's tabs",
"path": "/home/ybochkarev/.local/bin/bt_mediator",
"type": "stdio",
"allowed_extensions": [ "[email protected]" ]
}
and then try running bt_mediator
exactly as you see its path in path
field, e.g.
$ /home/ybochkarev/.local/bin/bt_mediator
That how Firefox would try to run it.
If that doesn't work, it could indicate that your env
when running from a terminal and when running by Firefox are different, e.g. PATH
could be different. In that that case we can dig further by examining the differences. You'll need to create a wrapper script, e.g. /home/ybochkarev/.local/bin/bt_mediator_wrapper
with something like this:
#!/bin/bash
env > /tmp/wrapper.log
/home/ybochkarev/.local/bin/bt_mediator
And then we can compare the output of env
when run from a terminal vs when run by Firefox.
Hey,
I have the same results as you:
ofirg@ofirg:~ $ cat /home/ofirg/.mozilla/native-messaging-hosts/brotab_mediator.json
{
"name": "brotab_mediator",
"description": "This mediator exposes interface over TCP to control browser's tabs",
"path": "/home/ofirg/.local/bin/bt_mediator",
"type": "stdio",
"allowed_extensions": [ "[email protected]" ]
}
and ~/.local/bin/bt_mediator
runs (no output to stdout/err)
Can't get brotab to work. I have tried to run ~/.local/bin/bt_mediator
and get ImportError: cannot import name 'url_quote' from 'werkzeug.urls'