title: wkhtmltopdf + ActionCable (error during websocket handshake)
body: <p><strong>SCENARIO</strong></p>
  
  <p>My rails application has a page that tooks a considerable amount of time to load. In order to increase our users' experience we decided to (firstly) only show a loader with an indication of how much of processing has been completed (instead of let them waiting blindly the response from server). That indication is shown with the helping of rails 5 ActionCable tool and once processing is completed the content is shown.</p>
  
  <p>Obviously, in order to make it possible, a subscription to a channel is made as soon as page loads so that server can report the processing status and the final result.</p>
  
  <p><strong>GOAL</strong></p>
  
  <p>Generate a PDF from that page so that we can email users with that file attached.</p>
  
  <p><strong>PROBLEM</strong></p>
  
  <p><strong>wkhtmltopdf</strong> is being used to generated the PDF but when accessing the page it isn't being able to handshake with ActionCable's websocket.</p>
  
  <p>The following message is raised:</p>
  
  <pre><code>Warning: http://localhost:3000:0 Error during WebSocket handshake: protocol mismatch: actioncable-v1-json,actioncable-unsupported != 
  </code></pre>
  
  <p>The above message intrigued me because it's like the protocol it'd accept for handshaking should be... blank?!! :O (notice the right hand of the operator <code>!=</code> - there is nothing there!).</p>
  
  <p>Under the hood I know wkhtmltopdf uses qt webkit browser. I suppose the solution for this problem would be related to some configuration within webkit (but I don't know how - neither where - to set it from wkhtmltopdf).</p>
  
  <p><strong>System Stack</strong></p>
  
  <ul>
  <li>Linux (Ubuntu) 16.04</li>
  <li>rails 5 + ActionCable</li>
  <li>wkhtmltopdf 0.12.3 (with patched qt)</li>
  </ul>