This is somehow related to another topic about URLs, but my goal is
I'm trying to add websocket support to on existing twisted site,
instead of having to run a specific service on a different port.
Just as an addition for people who are ok with running on
_different_ port .. that is trivial, i.e.
Its also easy to share session data between Web and WS objects when
a single Twisted reactor.
For example:http://www.example.com/chatserve the html page and
ws://www.example.com/ws/chatis the websocket URL.
Adding a twisted.web.resource would be the most natural way,
unfortunately there is currently no such class.
Have anyone tried that, or is there a plan to achieve it?
I did not try .. wasn't a goal to achieve. I'm not sure if
that can be done without modifying HTTPChannel or some other
code within Twisted itself. Dont know if there are appropriate
hooks. Because what needed to happen was, that after recognizing
a WS upgrade HTTP header, subsequent processing needs to be done
by the WS implementation, not the "normal" HTTPChannel etc any
For Autobahn, making that part/integrate of/with twisted.web
was not a goal and there are no plans to do so. My perspective is:
WS is - after the handshake - not HTTP any longer. Its also not
a "resource serving thing", like HTTP/twisted.web - its a connection
oriented full-duplex messaging channel. Quite a difference.
That said, if someone comes up with a clean/sane way of hooking
into HTTPChannel or the like, it could be a feature.
It is somehow possible to achieve the same with the txwebsocket
project with a "handler" mechanism and a special twisted.web.Site
class. Not as clean as with a resource, and modulo it is for hixie-76
only, but it works.
The author of txwebsocket has recently replied on the Twisted list
saying he plans to take up development again. Maybe look at that.
Just interested: why do you need to run Web and WS on same host/port?
Here is what we do regularily:
are routed by firewall to
10.0.0.0:8080 and 8090 which are run by a single Twitsed reactor
serving twisted.web on 8080 and autobahn on 8090.