how to log all phoenix.js websocket messages

    Quick phoenix.js websocket tip, log all messages

    This works for phoenix 0.16.1, not sure if it will continue to function this way.

    just add this as a 2ns arg to your new socket.

    var socket = new Phoenix.Socket("/status",{logger: (kind, msg, data) => { console.log(`${kind}: ${msg}`, data) }})

    This helps if your chan.on(“foo”,… is not working and you want to see what is happening under the covers

    more detail in the phoenix.js source code

    %{description: "logging all websocket messages to console", title: "how to log all phoenix.js websocket messages"}

  • (Optional) See our JavaScript configuration variables documentation for ways to further customize the Disqus embed code.


About this blog: This blog will discuss technology associated with my project. I am using Elixir and Phoenix for my backend, and React.js and Reflux for my front end. I have a library called Trabant to experiment with graph database persistence for Elixir. The views expressed on this blog are my own, and are not that of my current employer.

About Me: I am a hobbyist programmer interested in distributed computing. I dabble in Elixir, Ruby, and Javascript. I can't spell very well, and I enjoy golf.