[Twisted-web] Is there a good way to mount both an HTTP Site and a WebSocket Server on port 80?

Phil Mayers p.mayers at imperial.ac.uk
Mon Apr 9 05:03:08 EDT 2012


On 04/05/2012 02:55 PM, Tom Sheffler wrote:
> I was wondering about ways to mount different types of protocol handlers
> on the same port. It looks like there will be new WebSocket support
> implementing a websocket Site. We'll also have the existing HTTP Site.
> Will they both be able to live on port 80? Is it important to be able to
> do this?

Why would you do this?

IIRC WebSocket "switches" from HTTP into WebSocket mode; so what you 
actually want is for the HTTP Site (actually a Factory) to return a 
Protocol instance that:

  1. Handles HTTP
  2. Detects a WebSocket switch
  3. Creates a new WebSocket Protocol, attaches the existing transport, 
and deletes itself



More information about the Twisted-web mailing list