This is an example of using ports to work with the WebSocket API in Elm.
For an explanation of the approach, look at these files:
This demo does not handle binary messages. However, it should be possible to create a File from a binary message, send it to Elm and extract the Bytes via File.decoder. Unfortunately, there is no direct way to send binary data from Elm to JS, so some sort of string encoding would have to be used across the port for outbound binary data.
npm install
npm start