Merge conflick fix from cherry-pick

The Rendevous server wasn't passing on the closed connection from the dyno socket, so the Heroku client was never ending the session. So I added a listener.

I've also added some comments, I may be wrong about what the code does, so please feel free to correct me on it.

Also, this is a cherry-pick from my slotbox version of the apiserver, so the commit only contains changes to this one file. Strangely there was a merge conflict (I don't cherry-picking much) and so the original commit message was lost.

tom :)