January 5th, 2008
In November 2007 Adobe announced a Export SDK preview of there photo management application Lightroom. The Export SDK allows developers to write plugins for Lightroom which allow the user to export his photos to various places like Flickr, Smugmug or Picasa in an easy way.
On November 20th, 2007 Jeffrey Friedl announced its own Flickr Export Plugin and on November 26th RBerteig first commented about a FormatMessageW Error which occurs on Jeffrey’s and on the original Adobe Flickr Export Plugin.
A bit History of FormatMessageW Debugging
I for my part did not try any Export Plugin before January 1st, 2008. But as I did my first upload to Flickr, I got the FormatMessageW Error. I got it every time, not at some occurrences as others. As I went back to Jeffrey’s plugin site, I saw a big FormatMessageW Error box which told, that no one knows the reason behind this meaningless error. This let me start to debug Jeffrey’s plugin in order to get it working.
As the error occurs after a certain amount of time, I began make my photo smaller and smaller with the build-in resize control. On the standard Flickr size of boxed 500 px x 500 px my photo uploaded fine without the error. First I thought that the problem has something to do with the file size, I investigated the limit which was at about 600 kb. But than as I had a download running at the same time, the error also occurred at the small size. This brought me back into the time domain and at the end I knew that the FormatMessageW Error comes up after exactly 30 seconds.
After a bit of goggling, I found the Microsoft KnowledgeBase Article Internet Explorer error “connection timed out” when server does not respond within five minutes in which you can read:
By design, Internet Explorer imposes a time-out limit for the server to return data. The time-out limit is five minutes for versions 4.0 and 4.01 and is 60 minutes for versions 5.x and 6. Also, the time-out limit is 30 seconds for Windows Internet Explorer 7.
After reading a post on microsoft.public.inetsdk.programming.wininet called Increase timeout values. WinInet where Saju Paul says:
I have IE7 installed and I am using the WinInet library for http requests. There is a peculiar requirement in my app where I have to wait for a long time to get the response for the request I make calling HttpSendRequest. But the call times out after 30 seconds or so.
I came to the conclusion, that the timeout might be the problem. The reason is, that both the Internet Explorer and Lightroom use the same WinInet API for HTTP requests. If you read the not so helpful error message from Lightroom carefully,
An internal error has occurred: Win32 API error (unknown error --
FormatMessageW failed) when calling HttpSendRequest from
you can see that Ligthroom is calling
HttpSendRequest. The same API method as Saju Paul called and obviously the IE too.
A Workaround to FormatMessageW
The KnowledgeBase Article suggests a solution for the timeout problem which consists of setting a non-standard timeout in the Windows Registry. I tried it setting the timeout to 60 seconds and whoops the FormatMessageW Error occurred after 60 seconds. So setting it to any value you need can be considered as an first workaround to the problem.
But I would not recommend you to do this unless you need a solution today and you know what you are doing if you edit your registry. Note that Adobe is aware of this bug. Please read the thread FormatMessageW failed error – Solution in sight? on the Lightroom SDK forum where Eric Scouten says:
To be a little more clear about this, we have seen this happen occasionally, but not reliably. Only this morning did Alexander add the clue that it seems to be timeout related. (Thanks, Alex!) This might explain why we had less luck reproducing it using our internal LAN than some of you might have had using slower connections.
Before the holiday break, we did attempt a fix internally, but we’re not rushing to release it since we’re not convinced that we fully understand the cause of the bug.
That means that Adobe is aware of this bug until before the holidays and that they have my hint now to work on a solution. So I would guess that this problem will be solved in the next release of Lightroom.
For that folks of you who want set the timeout value to a non-standard value, please follow these steps:
- Be sure that you have WinXP SP2 with IE7 as I don’t be able to test this for Vista
- Shut down Lightroom and any application which uses the Internet Explorer
- Download the file formatmessagew-60.reg
- Double-click on this file in order to invoke it
- Answer the question “Are you sure you want to add the information in path of .reg file to the registry?” with yes
- Reboot your computer
Please note that this instruction is provided WITHOUT ANY WARRANTY. I can’t take any responsibility for any problem you might have because of this registry update.
To uninstall the registry patch, please download and execute the file formatmessagew-uninstall.reg.
What did the .REG file change in the registry? It adds a single DWORD value with the name
ReceiveTimeout and a value of 60000 (one minute) into the key
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings. This is the same as described in this KnowledgeBase Article.
The file formatmessagew-60.reg sets a timeout of only one minute. I provide it as an default, because higher values do not always work for me. But here comes a list of alternatives which sets a timeout as specified in the filename:
- 120 seconds: formatmessagew-120.reg
- 180 seconds: formatmessagew-180.reg
- 300 seconds: formatmessagew-300.reg
- 600 seconds: formatmessagew-600.reg
If you have any questions regarding the FormatMessageW and its workaround, please be free to ask here in the comments or in the SDK forum thread.
At the End
At the end of the day I thank Adobe for a great peace of software namely Lightroom and Jeffrey Friedl for his effort in rolling out a feature rich Flickr Export Plugin. I’m sure that Adobe will fix this bug and I’m looking forward for the full-fledged SDK.
I decided to provide an .REG file for the registry update. I hope that it makes it easier for you to apply the little patch.
I added an uninstall .REG file.
The problem is still present in LR 2 beta with an other error message, with says:
An internal error has occurred: ?:0: attempt to index a nil value
And it seems to not honor my registry patch. I tried the 60 second one but the error pops up after 30 seconds in LR 2 beta where LR 1.3.1 gets up to the 60 second barrier.