title: Is there any way to run Tungstenite on the same port as hyper?
body: <p>I'm trying to make a web server in Rust for a simple browser game. I want the server to be able to deliver pages through HTTPS, but also be able to communicate through WebSockets. I'm planning to put this server on Heroku, but since they only allow one port per application I have to make the WebSocket server operate on the same port as the other HTTPS code.</p>
  
  <p>It seems like <a href="https://stackoverflow.com/q/45806359/1753929">this is possible with crates like <code>rust-websocket</code></a>, but that crate uses an outdated version of <code>hyper</code> and seems to be no longer maintained. The crate <code>tokio_tungstenite</code> is much more up to date.</p>
  
  <p>The problem is that both <code>hyper</code> and <code>tungstenite</code> have their own implementation of the HTTP protocol that WebSockets operate over with no way to convert between the two. This means that once an HTTPS request has been parsed by either <code>hyper</code> or <code>tungstenite</code> there is no way to continue the processing by the other part, so you can't really try to connect the WebSocket and match on an error in <code>tungstenite</code> and process it by <code>hyper</code>, nor can you parse the request by <code>hyper</code> and check if it's a WebSocket request and send it over to <code>tungstenite</code>. Is there any way to resolve this problem?</p>