[Twisted-Python] Switching Protocols and TLS

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Wed Aug 29 09:53:01 EDT 2012


On 01:19 pm, tobias.oberstein at tavendo.de wrote:
>Hello,
>
>I am running a Twisted Web Site object that switches the protocol for 
>specific paths.
>The goal is to run Twisted Web, and have certain paths mapped to 
>WebSocket.
>
>I am aware of
>
>http://twistedmatrix.com/trac/ticket/3204
>
>but in the meantime have working code
>
>https://github.com/tavendo/AutobahnPython/blob/master/autobahn/autobahn/resource.py#L84
>
>This works for non-TLS, but not for TLS.
>
>This works perfectly:
>
>https://github.com/tavendo/AutobahnPython/tree/master/examples/websocket/echo_site
>
>and this does NOT work:
>
>https://github.com/tavendo/AutobahnPython/tree/master/examples/websocket/echo_site_tls
>
>The latter is able to send stuff down to client, but won't receive 
>anything.
>
>Any hint how to track that down would be great!

The `protocol´ attribute isn't part of the transport interface.  Some 
transports are implemented in a way such that changing that attribute to 
refer to a different protocol will produce the behavior you're after, 
but not all.  In particular, the transport implemented in 
twisted.protocols.tls (used to provide the transport whenever you use 
listenSSL, connectSSL, or startTLS) does not work this way.

You should be able to work out which attribute needs to be mangled by 
looking at twisted/protocols/tls.py.  My initial guess would be 
`wrappedProtocol`, but that's *only* a guess.  And of course, whatever 
you find is not going to be part of any formal transport interface 
either, so it's not guaranteed to keep working in the future, or to work 
with any other transport you might end up using - hence the desire to 
resolve #3204.

Jean-Paul



More information about the Twisted-Python mailing list