Thanks guys, In the end I don't know what solved it, I had changed too much code to know for sure and too many other things at the same time. I did however find tcpdump useful as a debug tool as the error messages don't always seem to make it back up the stack into php. I could read them in plain text in the network packets.
Thanks again.