crossbario / autobahn-python

WebSocket and WAMP in Python for Twisted and asyncio
https://crossbar.io/autobahn
MIT License
2.48k stars 768 forks source link

Replace old reactor listen/connect with endpoints in examples #504

Open oberstet opened 9 years ago

oberstet commented 9 years ago

Replace

in all Twisted examples (both WebSocket and WAMP) with Twisted endpoints.

glyph commented 6 years ago

Is the same issue as connectWS using these APIs?

meejah commented 6 years ago

@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.

glyph commented 6 years ago

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.

glyph commented 6 years ago

(In fact I would even suggest going a level deeper and using IAgentEndpointFactory from Agent, since you're dealing with URLs...)

meejah commented 6 years ago

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 ...)

glyph commented 6 years ago

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? :))

meejah commented 6 years ago

Here's a start: https://github.com/crossbario/autobahn-python/pull/1023

oberstet commented 5 years ago

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: