Using a single session seems to fix the socket error. Removing debug cruft now.