Open oberstet opened 9 years ago
Is the same issue as connectWS
using these APIs?
@glyph Probably .. there are technically endpoints for Autobahn WebSockets (see https://github.com/crossbario/autobahn-python/tree/master/twisted/plugins) but because a WebSocket connection is really "a URL, plus some other kind of transport" (and possibly some other information) this gets into the whole "protocol over another protocol" kind of thing and the endpoint strings for WebSockets thus get ugly (because you have to backslash-quote ":
" which appear in the sub-endpoint-strings).
I recall a discussion in Twisted about this general idea (i.e. "protocol A over protocol B" type situations) but no solution for nice endpoint strings in this case.
We managed something reasonable for wrapClientTLS
, but in this case, I don't even care about endpoint string plugins :). I'm just talking about endpoint objects, rather than connectTCP
et. al.
(In fact I would even suggest going a level deeper and using IAgentEndpointFactory
from Agent, since you're dealing with URLs...)
We've been using a higher-level thing than both of those for WAMP -- but then again, it's a higher-level thing anyway (e.g. https://autobahn.readthedocs.io/en/latest/reference/autobahn.twisted.html#component).
We don't have anything like the above (besides the existing Twisted endpoints) for WebSocket. Another piece here is the desire to have a similar (or at least consistent) API between Twisted and asyncio (but since asyncio lacks endpoints, we've departed already somewhat). Adding "a better way" to create WebSocket endpoints does make sense, though -- IAgentEndpointFactory
looks like good inspiration here, thanks!
(I think you mean "actually use that interface", but we could only do that for Twisted-side Autobahn code ...)
I understand the desire for consistency, but connectWS
looks like it's pretty twisted-specific already, so it should be using the good twisted-specific APIs? :)
(I see it also uses ssl.DefaultOpenSSLContextFactory
which absolutely gives me hives and should be deprecated and deleted. I know that's a separate issue, but can you please fix it ASAP? :))
Here's a start: https://github.com/crossbario/autobahn-python/pull/1023
we do have examples for websocket+endpoints
and for wamp using the new component API
but the docs for websocket still point out the "old" connectWS
thing:
Replace
reactor.connectTCP
reactor.listenTCP
reactor.connectSSL
reactor.listenSSL
in all Twisted examples (both WebSocket and WAMP) with Twisted endpoints.