question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use it on Windows Chrome

See original GitHub issue

First to thank you for this great tool. It’s Awesome!!

I managed to use it on Windows-Chrome.

That’s are the changes i’ve done.

Change SIGPIPE

On windows there’s no SIGPIPE signal. I’ve seen on the python docs that they advise to catch the exception BrokenPipeError:

From https://docs.python.org/3.7/library/signal.html#note-on-sigpipe

Changes on main function of brotab_mediator.py def main(): #signal.signal(signal.SIGPIPE, signal_pipe) monkeypatch_socket_bind() disable_click_echo()

global actual_port
for port in range(DEFAULT_MIN_HTTP_PORT, DEFAULT_MAX_HTTP_PORT):
    logger.info('Starting mediator on %s:%s...',
                DEFAULT_HTTP_IFACE, port)
    actual_port = port
    try:
        app.run(DEFAULT_HTTP_IFACE, port, debug=False, threaded=False)
        logger.info('Exiting mediator...')
        break
    except OSError as e:
        logger.info('Cannot bind on port %s: %s', port, e)
    except BrokenPipeError:
        signal_pipe

else:
    logger.error(
        'No TCP ports available for bind in range from %s to %s',
        DEFAULT_MIN_HTTP_PORT, DEFAULT_MAX_HTTP_PORT)

I think this way is compatible with all OS.

How to Configure for Chrome on Windows

A) Changes on brotab_mediator.json: Path entry must have double \

Example: "path": "D:\\Python-3.7.6.0\\Envs\\BroTab\\Scripts\\bt_mediator.EXE",

B) Create a Registry Key

From https://developer.chrome.com/extensions/nativeMessaging#native-messaging-host-location

On Windows, the manifest file can be located anywhere in the file system. The application installer must create registry key HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.my_company.my_application or HKEY_CURRENT_USER\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.my_company.my_application, and set default value of that key to the full path to the manifest file. For example, using the following command: REG ADD “HKCU\Software\Google\Chrome\NativeMessagingHosts\com.my_company.my_application” /ve /t REG_SZ /d “C:\path\to\nmh-manifest.json” /for using the following .reg file: Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Google\Chrome\NativeMessagingHosts\com.my_company.my_application] @=“C:\path\to\nmh-manifest.json”

In this case i’ve used : Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\brotab_mediator] @=“[PathWhereManifestFileIs]\brotab_mediator.json”

Enable Logging on Chrome

Just a quick note if you want to see what’s happenning on Chrome side…

From https://www.chromium.org/for-testers/enable-logging

To enable logging, launch Chrome with these command line flags:

–enable-logging=stderr --v=1 # Linux (newer instructions for Linux: here) –enable-logging --v=1 # Windows –enable-logging=stderr --v=1 > log.txt 2>&1 # Windows, seems to capture more output

Hope to get time to make it work on FF.

Edit : I cannot get any response from query command, in any of its variations. Always returns b’[]’

2020-02-12 17:40:00,818 19656 INFO       getting browser name
2020-02-12 17:40:00,818 19656 INFO       SENDING: {'name': 'get_browser'}
2020-02-12 17:40:00,819 19656 INFO       RECEIVED: b'"chrome/chromium"'
2020-02-12 17:40:03,751 19656 INFO       query info: eyJ1cmwiOiBbIio6Ly8qLmdvb2dsZS5jb20vKiJdfQ==
2020-02-12 17:40:03,752 19656 INFO       SENDING: {'name': 'query_tabs', 'query_info': 'eyJ1cmwiOiBbIio6Ly8qLmdvb2dsZS5jb20vKiJdfQ=='}
2020-02-12 17:40:03,755 19656 INFO       RECEIVED: b'[]'
2020-02-12 17:42:04,148 19656 INFO       getting browser name
2020-02-12 17:42:04,149 19656 INFO       SENDING: {'name': 'get_browser'}
2020-02-12 17:42:04,150 19656 INFO       RECEIVED: b'"chrome/chromium"'
2020-02-12 17:42:07,076 19656 INFO       query info: eyJ1cmwiOiBbIioiXX0=
2020-02-12 17:42:07,076 19656 INFO       SENDING: {'name': 'query_tabs', 'query_info': 'eyJ1cmwiOiBbIioiXX0='}
2020-02-12 17:42:07,077 19656 INFO       RECEIVED: b'[]'
2020-02-12 17:42:50,217 19656 INFO       getting browser name
2020-02-12 17:42:50,217 19656 INFO       SENDING: {'name': 'get_browser'}
2020-02-12 17:42:50,218 19656 INFO       RECEIVED: b'"chrome/chromium"'
2020-02-12 17:43:51,644 19656 INFO       getting browser name
2020-02-12 17:43:51,645 19656 INFO       SENDING: {'name': 'get_browser'}
2020-02-12 17:43:51,647 19656 INFO       RECEIVED: b'"chrome/chromium"'
2020-02-12 17:43:54,571 19656 INFO       query info: eyJ0aXRsZSI6ICIqIn0=
2020-02-12 17:43:54,572 19656 INFO       SENDING: {'name': 'query_tabs', 'query_info': 'eyJ0aXRsZSI6ICIqIn0='}
2020-02-12 17:43:54,575 19656 INFO       RECEIVED: b'[]'

Any clue?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
balta2arcommented, Feb 12, 2020

Thanks for the great and detailed write up! Your suggestions definitely need to be merged when I have a bit more time.

To enable logging, launch Chrome with these command line flags

That was and is a huge pain point for me. It was so inconvenient to check extension’s logs in a browser given that I work mostly in command-line. I’ll try that and I wish there were simple and reliable way to do the same in Firefox.

0reactions
balta2arcommented, Feb 16, 2020

It lacks the changes on brotab_mediator.json (Path to bt_mediator.EXE entry must have double ) and the creation of the Registry Key.

Added all your changes from the pull request and also implemented these two. Now Windows support should be much better.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use Chrome browser - Google Workspace Learning Center
Open a webpage in Chrome browser. · At the top right, click More "" and then Find. Or, use the keyboard shortcut Ctrl...
Read more >
4 Ways to Use Google Chrome - wikiHow
1. Install Chrome on your PC. If you haven’t yet installed Google Chrome, you can do so now for free. Here’s how to...
Read more >
How to Use Chrome Browser: Tips, Tutorials and Hacks
Get the most out of Chrome with this collection of tips, tricks, tutorials and hacks. We explain new features and which settings to...
Read more >
chrome.windows - Chrome Developers
Use the chrome.windows API to interact with browser windows. You can use this API to create, modify, and rearrange windows in the browser....
Read more >
Getting Started with Google Chrome
Accessing Chrome · If you are using Windows, Chrome will add a shortcut on your desktop. Whenever you want to open Chrome, just...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found