Posted on Monday 30 January 2006
The battle between good Remoting programmers and evil NetConnection.Call.BadVersion errors has finally come to an end. As you may know, fatal errors coming back from php fail to register in the NetConnection debugger, which makes it a major pain in the arse to debug if you don’t have access to an error log. The reason is that php spits out plain text errors while the NetConnection debugger expects amf data. Earlier I posted a solution which also required access to the error log that routed the errors from the error log to the NetConnection debugger. However I was ruminating a better solution to this issue that did not require access to the error log (as seems to be common on shared hosts).
Now I could whine and whine about people developing on live servers even though it’s way easier and safer to debug on local servers, but some bug pop up only when on the remote server, and then you’re screwed. So the plan was to create a fake gateway that would call the real gateway, and if the output from the real gateway looks error-like (does not start with chr(0), for instance), then wrap it in an amf message and show the error in the NetConnection debugger. I started on this a few months back but I never got a response back from the gateway and I had no idea as to what was the problem. After posting on the mailing list about my issue, I received no answer and so it remained a good idea that almost worked.
Now I noticed recently that the SabreAMF project includes a test client that uses cURL, and, fair enough, the author figured out how to do what I had been trying to do along (I believe the issue was a missing Content-type header).
In any case, I plugged the cURL code into my earlier attempt at a debug gateway and lo-and-behold… it works. Pimp. Basically all you need do is download and install amfphp 1.1 (I think it deserves a .1 release). During development, instead of pointing your service to amfphp/gateway.php, you point to amfphp/debuggateway.php. Fatal errors will now pop up in the NetConnection debugger. Simple as that.
If you already have 1.0 installed, you can also download debuggateway.php on it’s own here and place it next to gateway.php.
Caveats:
Sessions won’t work properly under the debug gateway(this was fixed in amfphp 1.1.1)- cURL must be enabled
- There is a performance hit associated with using the debug gateway. You should always point to gateway.php for production use.
Enjoy!


