The list of reasons for the infamous i/o error #2038 seems to be endless and considering the huge number of google hits [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] a lot of people are struggling with it. One of the reasons for this is that error #2038 is a very generic i/o error and doesn’t provide any further details that would help to track down the root problem. It even doesn’t state whether the error was client or server side.
In our case the error seemed to be client side, Mac only to be specific – “seemed to be” because we were proven different in the end. It happened that any file upload attempts initiated from Mac clients aborted with that particular error. Since we were able to upload the very same files with any Windows client we concluded that it can neither by the file size or type, nor any permission problems on the server. And since it only happened on Mac clients we further concluded that it has to be a bug in the Mac version of the Flash player.
We started to find the least complex setup to trace down the bug and finally file a bug report – and guess what, the very basic file upload example that can be found on so many tutorial pages worked. Well, that on the other hand proved that it is not a sole Mac player bug.
So if it’s neither a client bug nor a server bug, what else can it be? To solve that puzzle we set up Wireshark and started to compare the network traffic between our not working web application and our working test environment and the respective client. The first interesting thing we discovered was that in the failing case the client not even attempted to upload something. Why the heck can something fail that was not even tried to be done?
After further investigation of the network traffic we finally found the problem! It turned out to indeed be a Mac player bug that only arises with certain webserver configurations. More specifically, our webserver had some redirection rules in place that aimed to correct broken links, enforce https, and such. The problematic rule was the one that appended a slash to all requests that addressed a directory but ommited the trailing slash, and the upload request turned out to be such a request. While the Windows version of the Flash player understood that redirect and re-uploaded the file to the new location the Mac player just dropped the connection and bailed out with that ominous i/o error.
The fix was an easy one, we just added a trailing slash to the upload URL specified in the Actionscript code and everything worked fine.