Search code examples
google-chromegoogle-cast

How do I debug the connection/message flow of my Chrome Sender Application?


I am having problems:

  1. Getting a list of receivers, or
  2. Connecting to a receiver, or
  3. Sending messages to a receiver, or
  4. Receiving messages from a receiver

Given that the injected Cast API does not provide any logging (debug console, Network panel, or otherwise) when developing a Chrome Sender App for the Google Cast, how can I trace and track the DIAL requests and the Cast WebSocket messages?


Solution

  • To get some better insight as to the flow of getting a list of receivers, connecting/launching your application, and the messaging, it may be helpful to use Inspect the Background Page of the Google Cast Extension that you have installed into your browser. To do this:

    1. Open the Extensions page in Chrome (Settings -> Tools -> Extensions)
    2. Enable "Developer Mode" by checking the checkbox
    3. Find the Google Cast Extension in the list
    4. Click the link next to "Inspect views:" labelled "background.html"
    5. This should open a Chrome Inspector tab

    There is some logging done by the Extension itself. Additionally, by selecting the "Network" tab you can see the outgoing requests/responses and the WebSocket connection once initiated. After selecting the WebSocket connection, you can switch from the "Headers" tab to the "Frame" tab within the right pane to see WebSocket messages. The list will not automatically refresh, but you can click the WebSocket connection in the list on the left and it should update.