Http + ws on same port

Without using nginx or some type of port forwarding, is it possible to run http and websocket on the same port?

This requires something called ‘upgrading’ a http connection, to take it from http to websocket.

The closest I have found is this blog post:

but I don’t see how to get from the code fragment to actual working code. (Also, it seems to be using hyper 0.11 instead of hyper 0.12).


Is there working code anywhere of http + websocket on same port?

actix-web ( let you do that easily.

Does this upgrade example from hyper help?

I saw this example before, but could not figure out where the websocket is. I found nothing searching that page for “websocket” and “ws”

I’m new to the rust ecosystem. Can you please point out:

  1. what struct/‘noun’ is websocket in that example
  2. where the open, send, recv are?


Yes, it doesn’t show the WS part, only the upgrade part.

The second part to look at is something like this:

(Sorry for the terse reply, hopefully someone can give a more detailed answer)