FormatMessageW Error in Lightroom Export Plugins

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,

  1. An internal error has occurred: Win32 API error (unknown error --
  2. FormatMessageW failed) when calling HttpSendRequest from
  3. private_AgHttpClient_post_L

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:

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.

Update

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.

Update2

I added an uninstall .REG file.

Update3 (04.04.2008)

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.

34 Comments

  1. 1. January 6th, 2008 by Thomas | permalink

    Hi Alexander,

    Thanks for looking into this. I tried it on Vista with the 180 second timeout and it worked like a charm-thought others might be interested in this info.

    are there any possible other side effects of using this method that you know about? Thomas

  2. 2. January 7th, 2008 by Curt Norton | permalink

    Thanks for this workaround. I installed every one of these starting with the 60.reg. When I reached the 300.reg that was the point at which I could upload multiple files without the error. Do you happen to know what consiquences this might have in changing the registry to these values? This makes things so much better to be able to use the uploader directly. I appreceiate you effort.

    Curt

  3. 3. January 7th, 2008 by Mike Riddell | permalink

    I tried 3 .reg adds but still have the problem. I tried 180, 600, and 60 seconds (I just installed each, tried it, and then installed the next without deleting anything…I assume that’s OK). Before, I got one image into SmugMug, now I get two (same for all fixes). Any thoughts on what I can do?

    Mike

  4. 4. January 8th, 2008 by Alexander Kiel | permalink

    Thomas: Thanks for Vista testing and I’m not aware of any side effects — look at what I say to Curt.

    Curt: Nice to hear from you, that my registry patch helps you. I don’t know it for sure as I’m not so strong involved in Windows systems, but my experience tells me that the registry patch is mostly harmless. All what it did is raising a timeout value. The only disadvantage of a higher timeout is that you have to wait longer in case of a network error to get an error message.

    Mike: Yes its OK to install one .REG ofter another without uninstalling anything. The registry patch affects every single photo upload at once and not the whole batch. So I assume your second photo is much bigger in file size as your first. Please try to upload photos with similar or less file size than the first and they should all upload fine.

  5. 5. January 10th, 2008 by Jean-Luc Delpech | permalink

    Regarding the side effects; since you’re changing the time out for IE7, any program (incl. IE7) that uses this API (namely, WinInet) will use that (longer) time out. I’m a developer for a financial software company and we use WinInet to download tax law updates. These programs will be affected too. So, this may impact other softwares as well, some of them may be running in the background without you noticing them.

  6. 6. January 10th, 2008 by Alexander Kiel | permalink

    Jean-Luc Delpech: Yes I’m aware that this effects everything which uses WinInet. Except for an slightly different behavior in error (timeout reason) case, do you think that a longer timeout has any other impact to software using WinInet?

  7. 7. January 10th, 2008 by Jean-Luc Delpech | permalink

    Alex; It’s hard to tell what exactly can be impacted since we’re talking about a fairly low level change here, in a library that can potentially be used by many other softwares or even services (as in Windows Services). Who knows (besides the developers who built it :-) what a specific software does on return of a timed-out API? Some programs may be poorly designed and rely on a certain time out value to be lower than a max limit. All I’m saying is that this “fix” can have side effects that an every day/non-developer user may not even be aware of. To answer your question, I’m not expecting these side effects to be harmful (unless, as described above, a software is badly designed or badly tested), the only thing I can think of is that certain behavior may change or be delayed due to the increased time out. For instance, a user could change that time out and then realize that something else (some software that looks completely unrelated to LightRoom or a LR plugin) behaves differently now, takes longer to react or message the user on reception of certain events (antivirus can’t get the virus DB and message the user 5mn later than usual). We, as developers, can eventually reconcile these events, but a regular user might pick up their phone and call Adobe, or, worse (and more likely), the software maker that got unintentionally impacted. My take on this is that a smugmug user (like me) who uploads thousands of pictures to the smugmug web site, probably already has an uploader, so the plugin, although very cool and convenient, is not critical to have right now. IMHO, I’d follow your recommendation above and wait for Adobe to fix the problem in their SDK then download the lightroom update when available.

  8. 8. January 10th, 2008 by Mike Riddell | permalink

    File size worked except certain images were deleted. The Lightroom gallary contains images from 2 cameras plus some panographs. Where does the file size error occur and will it be fixed?

  9. 9. January 10th, 2008 by Alexander Kiel | permalink

    Jean-Luc: Thanks for your insights.

    Some programs may be poorly designed and rely on a certain time out value to be lower than a max limit.

    What let me hope, that few applications relay on the default 30 seconds timeout is, that it was 60 minutes with IE6.

    IMHO, I’d follow your recommendation above and wait for Adobe to fix the problem in their SDK then download the lightroom update when available.

    Yes that is what I would recommend to anyone. I wrote this post for that folks who be aware of the problem and want a solution now.

    Mike:

    Where does the file size error occur and will it be fixed?

    The problem at which the FormatMessageW error occurs is the amount of time it takes to upload every single photo. If you don’t apply one of my .REG patches, the FormatMessageW will show up at every file which takes more than 30 seconds to upload. If you have some big panoramas, it is possible that a normal file uploads fine but the big panorama not.

    The best way to see if my patches work, is to upload the files one by one and looking at a stop watch. If you load my 300.reg patch an upload up to 5 minutes (per file) should be fine.

  10. 10. January 11th, 2008 by Glenn Broadway | permalink

    Whilst this fix worked for LightRoom it messed up my computer elsewhere. For example, opening the Page Setup dialogue box in MS Word would take for ever.

    Returning the Value to 60 fixed word, but I can’t get back to exactly how it was before. In Photoshop it now takes a long time to either open a new file or create a new canvas. I’ve tried resetting the value to 30 (by editing the file you provide) as well as other values also (15, 45) but nothing will get PS back to opening files quickly.

    Bollocks.

    Any ideas?

  11. 11. January 11th, 2008 by Alexander Kiel | permalink

    Glenn: I’m sorry that you have problems with my patch. For that reason I added a uninstall .REG file. If you execute it, it will remove the registry value completely as this was the state before applying one of my patches.

    I tried open a empty new file (canvas) in Photoshop CS3 with the 60 second patch and without it. I couldn’t see any difference in speed on my system. I have WinXP SP2 and its an old IBM ThinkPad X30.

  12. 12. January 17th, 2008 by RBerteig | permalink

    Alexander, I think you’ve identified the issue and found a really easy work-around. As seems too typical, the actual error reported is not directly related to the actual problem which only adds to the fun.

    I applied a nice long timeout, and am not only not having any negative side effects in general web browsing, LR, PS CS2, Eclipse, NetHack, or any other tool or toy I run here from time to time, but now Friedl’s Flickr plugin is finally living up to its promise for me.

    Add my thanks to the pile…

  13. 13. January 22nd, 2008 by JamesR | permalink

    Hello,

    I’ve tried the fix (set to 600 seconds) and it doesn’t seem to help me. It will just product an error saying file size uploaded doesn’t match. And Give MD5 error after the specified time is up.

    Very frustrating.. Hope a fix from Adobe comes soon.

    -jr

  14. 14. February 1st, 2008 by Steve | permalink

    It may be that the seemingly intermittent success of the reg hack may be due to two things, photo size and upload speed. In fact, the reason why the problem itself is intermittent amongst different users may be due to these two factors. I would suggest those experiencing problems perform an online bandwidth test (google bandwidth test) and noting the upload speed and then note the size of the particular photo that you are trying to upload.

  15. 15. February 4th, 2008 by Doodee | permalink

    Thanks for sharing

  16. 16. February 5th, 2008 by microsoft vista error windows failed to start | permalink

    microsoft vista error windows failed to start…

    no kidding!…

  17. 17. February 6th, 2008 by Lightroom till Flickr erfarenheter at Teknobabbel | permalink

    [...] filmeddelandet lät inte vänta på sig. Alexander Kiels lösning fungerade lyckligtvis alldeles utmärkt. För mina behov verkar en ökning av timeout-tiden till 60 [...]

  18. 18. February 11th, 2008 by Ryan Dlugosz | permalink

    I get the errors mentioned above but experience something even more strange - Using the LR upload to SM completely kills my internet connection! I need to physically reset my router in order to fix the problem.

    Bizarre!!

  19. 19. February 18th, 2008 by Tiago Claus | permalink

    Hi. Thank you very much for the time and the solution.

    I tried on Vista SP1 with 60 seconds, but it did not work. Then with 120 seconds, that worked perfectly.

    Kind regards, Tiago

  20. 20. March 6th, 2008 by David | permalink

    It works like a charm. I even suspect the Flickr Uploader suffered from the timeout problem as well when it delivered a “Ooops - some of your photos have not been uploaded” message.

    So: Thanks a bunch!

    David.

  21. 21. March 22nd, 2008 by Pavan Chander | permalink

    I’m running 1.3.1 on Vista and I get the error, but it seems that the image does indeed upload to Flickr ocasionaly even when it shows the error.

    Sometimes it uploads two of the same image, or will only upload a few of the selected images.

    And no, I havn’t applied the registry patch.

  22. 22. March 24th, 2008 by Alexander Kiel | permalink

    Pavan: I can share your observations. Even if LR says that the upload fails, it will upload the image on which the error occurs to flickr. The reason is simple: The error LR is showing, is a timeout error. LR starts the rather big upload and waits only 30 seconds for its completion. After that time LR complains about that it doesn’t get any answer to the request and thinks it will be broken. But it isn’t.

    The upload is handled by Windows in the background and sill keeps going on. You can observe this with a network scanner like ngrep under Linux. I have a Linux gateway here though which all traffic goes, so its easy for me to monitor all this stuff. With ngrep I see the upload still running after LR show the error.

    But if you have a multi image upload, the next image would not start to upload since LR is supposed to do this on its own. But after the error LR does not try to upload the next image.

    So one workaround to get the uploads working is to upload one-by-one and ignore the error at all.

    One side note: You don’t have to post your comment twice. The reason it is not available immediately is that I have to approve it. I use this system until I get a good spam protection running. Sorry for this.

  23. 23. April 18th, 2008 by Steev Gallegos | permalink

    Leave to a developer to have to come in and fix an architects incomplete design. I have to go up to 5 minutes for larger file, but everything is working great. This shortens my work flow. Thank for fix.

  24. 24. May 12th, 2008 by david | permalink

    “So one workaround to get the uploads working is to upload one-by-one and ignore the error at all.”

    sorry but it is not a good workflow ;) i think the timeout fixed at a more long time is better because LR still process the image, even if the UL is defer

  25. 25. May 30th, 2008 by Chris | permalink

    I never had this problem untill I switch from Vista 32bit to 64bit.

    My errors says “An internal error has occurred: win32 API error (unknown error — FormatMessageW failed) when caling HttpSendRequest from private_AgHttpClient_post_L”

    Do you think this is an issue with running lightroom on a 32bit OS? And are you running it on a 32bit or 64bit OS?

  26. 26. June 19th, 2008 by Chris | permalink

    Fantastic work researching this. Worked a treat.

  27. 27. June 22nd, 2008 by Stefan Scholz | permalink

    lightroom 1.3, vista business, 180sec. –> works like a charm, thanks a lot!

  28. 28. July 8th, 2008 by Wolfgang | permalink

    I’m getting the error when my DSL connection is heavily used by up-/downloads, for example when a bittorrent is running, loading the current openSUSE. After closing the bittorrent client, I don’t get the error any more..

  29. 29. July 14th, 2008 by Werner Wattenbergh | permalink

    Another workaround that works for me is lowering the quality percentage for jpegs to less than 100%. Since I did this (I have it 99%) I never received a FormatMessageW error. I didn’t even have to alter the timeout values.

  30. 30. July 27th, 2008 by Adam | permalink

    I’m also receiving this error. I noticed someone else mentioned that they saw it on 64 bit vista which is what I’m also running. Any news on a fix ?

  31. 31. July 27th, 2008 by cashoob | permalink

    Vista Ultimate - Asus A7SV Clean installation of L1.4.1 - same error, no way to use a plugin…reg modification does not help at all…but if: 1. Install Java first 2. Install L1.0 3. Install L1.3.1 in same folder (L1.0 - Adobe Lightroom) 4. Install L1.4.1 in same folder (L1.3.1 - Adobe Lightroom), soft is going to do major upgrade…of files, etc… …then all works like a baby…no problems at all…

    …good luck dear friends…

    Regards Mark

  32. 32. July 28th, 2008 by Eoin | permalink

    Thanks for solution worked on Vista Hom Premium increased to 60000. Thanks after trying to get LRMogrify and Piglet working I was beginning to point the finger in the wrong direction till I found your workaround. Great work Eoin

  33. 33. July 28th, 2008 by Alexander Kiel | permalink

    Adam: Sorry no news on a 64 bit fix. I don’t have Vista at all and I also don’t have 64 bit XP.

  34. 34. October 20th, 2008 by dsl gateway router | permalink

    dsl gateway router…

    I found your post comments while searching Google. Very relevant especially as this is not an issue which a lot of peaople are conversant with….

Post a Comment


Line breaks are converted automatically. You may use Markdown syntax if plain text is not enough.