crossbario / crossbario/autobahn-python

WSS over explicit proxies not implemented for asyncio

Open
#1,250 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.5k
Forks
768
PR merge metrics
No merged PRs in 30d

Description

Steps to Reproduce

  1. Use asyncio
  2. Use the Component API
  3. Pass a proxy in the transport for a wss router
  4. Invoke sample code thusly: sample.py wss://myrouter.com/ws realm1 myproxy.com:3128

Expected Result

autobahn connects successfully

Actual Result

2019-09-27T14:10:02 connecting once using transport type "websocket" over endpoint "tcp"
2019-09-27T14:10:02 Exception in callback WebSocketAdapterProtocol._consume.<locals>.process(<Future finished result=None>) at /home/fferrell/src/proxy_example/venv/lib/python3.6/site-packages/autobahn/asyncio/websocket.py:106
handle: <Handle WebSocketAdapterProtocol._consume.<locals>.process(<Future finished result=None>) at /home/fferrell/src/proxy_example/venv/lib/python3.6/site-packages/autobahn/asyncio/websocket.py:106>
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/home/fferrell/src/proxy_example/venv/lib/python3.6/site-packages/autobahn/asyncio/websocket.py", line 110, in process
    self._dataReceived(data)
  File "/home/fferrell/src/proxy_example/venv/lib/python3.6/site-packages/autobahn/websocket/protocol.py", line 1213, in _dataReceived
    self.consumeData()
  File "/home/fferrell/src/proxy_example/venv/lib/python3.6/site-packages/autobahn/websocket/protocol.py", line 1232, in consumeData
    self.processProxyConnect()
  File "/home/fferrell/src/proxy_example/venv/lib/python3.6/site-packages/autobahn/websocket/protocol.py", line 3514, in processProxyConnect
    self.startTLS()
  File "/home/fferrell/src/proxy_example/venv/lib/python3.6/site-packages/autobahn/asyncio/websocket.py", line 230, in startTLS
    raise Exception("WSS over explicit proxies not implemented")
Exception: WSS over explicit proxies not implemented

Sample Code

import sys
from autobahn.asyncio.component import Component, run

proxy_host, proxy_port = sys.argv[3].split( ':' )

comp = Component(
    transports = dict(
        url = sys.argv[1],
        proxy = dict(
            host = proxy_host,
            port = int( proxy_port )
        ),
    ),
    realm = sys.argv[2],
)

@comp.on_join
def joined( session, details ):
    print( 'session ready' )

run( [ comp ] )

Notes

This works with twisted. Change the import in the sample code to autobahn.twisted.component and it connects as expected.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with autobahn/asyncio/websocket.py, especially WebSocketAdapterProtocol.startTLS, and follow the proxy path into autobahn/websocket/protocol.py at processProxyConnect. Compare the asyncio behavior with the working Twisted implementation and verify the sample.py WSS connection through an explicit proxy succeeds without the reported exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.