This preview environment blocks external WebSockets for security reasons. PeerJS requires WebSockets to establish the initial connection.
The code is fully working.
To test the application, run it outside this sandbox: