Fix sending JSON messages

This fixes a major bug (couldn't send JSON at all) and also has a bunch of fixes to integration test setup and diagnostics.

When we couldn't connect to sbt server at all, integration tests still passed. That's why the "can't send any messages at all" bug could exist.



0 is the null/invalid ID. It's sort of significant that it's 0 since lots of code assumes the ids are nonzero and ascending. I think comprehensively changing it to a constant should be its own pr though.