Developer forum

Forum » CMS - Standard features » WebP images with Cloudfront

WebP images with Cloudfront

Anders Ebdrup
Anders Ebdrup
Reply

Dear Dynamicweb,

 

We are trying to setup cdn with Cloudfront for our WebP-images, but get this error:

 

[ArgumentNullException: Value cannot be null.
Parameter name: source]
   System.Linq.Enumerable.Contains(IEnumerable`1 source, TSource value, IEqualityComparer`1 comparer) +371
   Dynamicweb.Admin.ProcessImageHandler.GetParameters() in E:\Agent\_work\170\s\01 - Applications\Dynamicweb.Admin\DW99\Dynamicweb.Admin\Admin\Public\GetImage.ashx.vb:281
   Dynamicweb.Admin.ProcessImageHandler.ProcessRequest(HttpContext context) in E:\Agent\_work\170\s\01 - Applications\Dynamicweb.Admin\DW99\Dynamicweb.Admin\Admin\Public\GetImage.ashx.vb:205
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +790
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +88

Can this be solved?

 

Best regards, Anders


Replies

 
Martin Vang
Martin Vang
Reply

Hi Anders,

I would guess that you specified the Format to be webp and then didn't supply the AcceptTypes. Can you try with a different image format or by also providing the AcceptType of "image/webp"?

BR

Martin

 

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Martin,

 

I works for other image formats than WebP, so any idea how to get CDN to work for WebP images?

 

Best regards, Anders

 
Martin Vang
Martin Vang
Reply

Hi Anders,

Thank you for testing. Yea, then I think you can get this to work, if you somehow provide the AcceptType for the GetImage requests. I honestly don't know which device is being used that don't provide this - is it a webapi with postman maybe? If it is, you can write the AcceptType as a parameter for the request.

BR

Martin

Update: Headers under the postman query: Add "Accept" with value "image/webp"

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Martin,

 

Thank you for the response here. We have now managed to get CDN working for WebP images.

 

Best regards, Anders

 
Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

Hi Martin,

We ran into this too and were going to report the same thing. Ours' was similar. We received the same null exception due to not having any AcceptTypes. For us, it failed from a load testing agent which, apparently, doesn't include any AcceptTypes. 

The line of code where the exception occurred is:

   Dim webPSupported As Boolean = _context.Request.AcceptTypes.Contains("image/webp")

It only occurs since the WebP code was introduced since that assumes that AcceptTypes are valid http headers. 

Thanks,

Scott

 

 

 
Martin Vang
Martin Vang
Reply

Hi Scott,

I totally get what you're saying, but it's strange to do a request that specifies that you want a specific format, but that does not accept that format as the return value. I know it's a bug, but it's a very strange setup and not something that can affect typical use of DW - only test setups that are slightly misconfigured.

Anyway, I'll of course look into it.

BR

Martin

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Scott,

 

We managed to fix the issue by added "Accept" to the headers of the request. See this setting: https://www.screencast.com/t/FWpGj6g5jsUV

 

I hope this can solve your problem?

 

Best regards, Anders

 
Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

Thanks Anders. That makes perfect sense, and it's what we did too.

Martin, the idea with the WebP format is that browsers need to opt-in. The problem is that some CDN code, and load testing agents (like JMeter) can send a request without any AcceptTypes at all. The WebP code fails on that rather than gracefully falling back to non-WebP support. It's kind of misconfigured, but it's kind of ok too. It's just a real simple agent that doesn't include any AcceptTypes. 

At least the solution is easy, which is to check for nulls (AcceptTypes) and default webPSupported to false.

Scott

 
Anders Ebdrup
Anders Ebdrup
Reply

I agree, Scott :-)

 
Martin Vang
Martin Vang
Reply
This post has been marked as an answer

Hi Scott (and Anders),

I completely understand the problem (at least I think I do), but the requested bugfix is not going to solve your problem with the tool.

If you forgot to specify Accept, and the null pointer bug is fixed, then specifying the format as "webP" results in you getting "jpg" back out. I was confused, but that's what the code does, and it's very much made like this on purpose, so we need to discuss a change of behavior (with the original developer who made this) to be able to "fix" it.

So I shortcircuited a bit and gave you a fairly simple fix on the setup side that will get you back on track with productive work, instead of having to create an endless stream of bugreports. It also gives me a bit more time to poke at the problem and trying to figure out how to deal with it in a way that actually fixes the issue with the tooling you're using ;-)

 

Anyway, the bug (the nullpointer one) has been fixed, and should be pushed to a release-channel soon. I think Nicolai or QA will create a post about it once we know which package will contain the fix.

BR

Martin

Votes for this answer: 1
 
Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

Hi Martin,

I bet that is everything that was needed. It's actually more simple than it sounds. The issue isn't occurring because we want WebP, but rather, because a simple agent is calling the image handler without sending AcceptTypes, and the WebP code wasn't expecting that situation to occur. So it's not WebP that is the problem per se ... it's just that an unrelated agent doesn't include the AcceptTypes in the request, triggering the null exception. Hopefully that makes sense.

Your fix to the null exception should take care of it!

Scott

 

You must be logged in to post in the forum