racinette / websockets_proxy

Connect to websockets through a proxy server.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error trying to run the example

Maxhem2 opened this issue · comments

Hi there, greate repo and exactly what I'd need but when trying to setup your example server and client scripts I always encounter this error.

Your IP: 127.0.0.1
.
Traceback (most recent call last):
  File "c:\Users\Jan\Downloads\websocket_tests\myenv\Lib\site-packages\python_socks\async_\asyncio\_proxy.py", line 93, in _connect
    await connector.connect(
  File "c:\Users\Jan\Downloads\websocket_tests\myenv\Lib\site-packages\python_socks\_connectors\socks5_async.py", line 69, in connect
    reply: socks5.ConnectReply = conn.receive(data)
                                 ^^^^^^^^^^^^^^^^^^
  File "c:\Users\Jan\Downloads\websocket_tests\myenv\Lib\site-packages\python_socks\_protocols\socks5.py", line 347, in receive
    reply = ConnectReply.loads(data)
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Jan\Downloads\websocket_tests\myenv\Lib\site-packages\python_socks\_protocols\socks5.py", line 209, in loads
    raise ReplyError(msg, error_code=reply)
python_socks._protocols.errors.ReplyError: Connection not allowed by ruleset

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Jan\Downloads\websocket_tests\script.py", line 27, in <module>
    asyncio.run(main())
  File "C:\Users\Jan\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Jan\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Jan\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 684, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "c:\Users\Jan\Downloads\websocket_tests\script.py", line 19, in main
    async with proxy_connect(CHECKER_URL, proxy=proxy) as ws:
  File "c:\Users\Jan\Downloads\websocket_tests\websockets_proxy\websockets_proxy.py", line 50, in __aenter__
    sock = await self.__proxy.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Jan\Downloads\websocket_tests\myenv\Lib\site-packages\python_socks\async_\asyncio\_proxy.py", line 59, in connect
    return await self._connect(
           ^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Jan\Downloads\websocket_tests\myenv\Lib\site-packages\python_socks\async_\asyncio\_proxy.py", line 108, in _connect
    raise ProxyError(e, error_code=e.error_code)
python_socks._errors.ProxyError: Connection not allowed by ruleset

Judging from the fact that your IP is 127.0.0.1, it seems like you're trying to connect to localhost through a remote proxy server, which you cannot do.

You need to make your proxy checker server remotely connectable: open ports, set up firewall rules, etc.
It's out of this package's concern.

If you connect to a remote server, everything will work fine.

Closing this as unrelated.