为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Remote debugger not working

more options

Hi!

I want to remote debug from python script.

In dev tools settings page I have checked: Enable browser chrome and add-on debugging toolboxes Enable remote debugging

And when I check about:config there it also shows: devtools.debugger.remote-enabled: true devtools.debugger.remote-host: localhost devtools.debugger.remote-port: 6000 devtools.debugger.remote-timeout: 20000 devtools.debugger.remote-websocket: true.

When I go to tools > browser tools > Browser toolbox then it asks if I want to allow connection and if I press ok then it works.


However when I run the following python code: import asyncio import websockets

async def connect_to_firefox():

   async with websockets.connect('ws://localhost:49928/devtools/browser') as websocket:
       # Now you have a connection to Firefox using the remote debugging protocol
       # You can send commands and receive responses through the WebSocket connection
       # For example, you can send a request to get the list of available browser tabs
       request = '{"id": 1, "method": "Browser.getBrowserList", "params": {}}'
       await websocket.send(request)
       response = await websocket.recv()
       print(response)
  1. Run the connection coroutine

asyncio.get_event_loop().run_until_complete(connect_to_firefox())


Then I get: ConnectionRefusedError: [WinError 1225] The remote computer refused the network connection

Question: Why does browser toolbox work but python script doesn't?

Hi! I want to remote debug from python script. In dev tools settings page I have checked: Enable browser chrome and add-on debugging toolboxes Enable remote debugging And when I check about:config there it also shows: devtools.debugger.remote-enabled: true devtools.debugger.remote-host: localhost devtools.debugger.remote-port: 6000 devtools.debugger.remote-timeout: 20000 devtools.debugger.remote-websocket: true. When I go to tools > browser tools > Browser toolbox then it asks if I want to allow connection and if I press ok then it works. However when I run the following python code: import asyncio import websockets async def connect_to_firefox(): async with websockets.connect('ws://localhost:49928/devtools/browser') as websocket: # Now you have a connection to Firefox using the remote debugging protocol # You can send commands and receive responses through the WebSocket connection # For example, you can send a request to get the list of available browser tabs request = '{"id": 1, "method": "Browser.getBrowserList", "params": {}}' await websocket.send(request) response = await websocket.recv() print(response) # Run the connection coroutine asyncio.get_event_loop().run_until_complete(connect_to_firefox()) Then I get: ConnectionRefusedError: [WinError 1225] The remote computer refused the network connection Question: Why does browser toolbox work but python script doesn't?

所有回复 (5)

more options

Ok since this site does not allow editing posts, I have to post clarification as a new comment: I tried to connect port 6000 at first. Only later tried 49928 because this is what browser toolbox seems to use. But both fail with same error.

more options

Are you using the Marionette interface:

https://firefox-source-docs.mozilla.org/testing/marionette/Intro.html

By default, marionette.port is set to 2828. Can you connect on that port?

more options

That didn't work either. I just thought I could use browser toolbox functionality remotely. Not sure if it is Marionette or something else.

more options

You can find "Edit this question" under the "Question Tools" menu in the sidebar. For a reply, "Edit this post" is in the three-dot menu next to a reply.

more options

This edit option is only for my replies, not for the main post.