Stream a remote screen with WebRTC

Recently I partcipated in a project that involved some server-side GPU rendering, due to the nature of the technologies we used we needed to run an X server on our boxes. The initial setup was relatively painless until a weird bug started appearing in some server and the logs didn’t provide enough information to debug effectively, this is how I ended up coding a remote viewer that streamed a remote server “screen” using WebRTC.