Problems with Ads from localhost in Development

2,320 views
Skip to first unread message

Goldy Lamont

unread,
Oct 26, 2015, 4:55:54 PM10/26/15
to Interactive Media Ads SDK
Hi, I am using the iOS9 SDK (installed using CocoaPods: pod 'GoogleAds-IMA-iOS-SDK', '~> 3.0.beta.16'). I am able to play both video and ads. However, I get an error when trying to play an ad when I use my local development server to return VAST tags. 

I get this error:  Error loading ads: Unable to request ads from server due to network error.

I am required to use our private server as a proxy to request all VAST tags through for our app. So I am testing in development that our iPhone app can retrieve and play ads.

So here are a few things that I've already verified:
  1. My local dev server is working fine and is serving VAST tags correctly--I have tested the exact same URL to my dev server using a different video player and the VAST tag is processed fine and the ad plays on a different player (JWplayer and Veeso player work). This error only occurs using the Google player. I know the first instinct is to think that my dev server is somehow not working correctly, but again if I use a different player in my iOS9 app it works fine, the VAST tag is fine and the ad plays ok.
  2. The Google player can play the exact same ad/vast tag fine if I tell it to grab the ad from the internet instead of from my local dev server. The ad itself doesn't seem to be an issue. Also the Google player can play several other ads fine from different internet URLs return a VAST tag.
  3. App Transport Security is completely disabled. This is a non-issue
  4. So, everything works with the Google player, except when I try to get the ad from >> http://localhost/vast_tag
    1. But--even though the error says there's a network error, this is incorrect! The Google player *does* make a request to my localhost, and my localhost sends back the VAST tag
    2. Actually, even though I get the network error, there are TWO requests actually made to localhost that I see in my log files, and my server returns a properly formatted xml vast tag both times
So in summary, only when using Google player and only when requesting a vast tag from my local dev server, I get the error above. Irregardless of the error above, the Google player does send 2 requests (about 1 second apart) and received two valid responses from my dev server (status code 200/OK). And using alternate video players they can play ads from my local dev just fine.

The only thing I can think of is that IMAAdsRequest (or similar) is somehow filtering or auto-erroring out due to something it doesn't like in my URL? I mean it does make the request (actually it does it twice) but then says it fails to network errors. I can then use an internet address for the same ad tag and the ad plays fine. I can't seem to figure out exactly where and why this error occurs...

Thank you!

Tyler Sidell (IMA SDK Team)

unread,
Oct 26, 2015, 5:16:28 PM10/26/15
to Interactive Media Ads SDK
Hi Goldy,

We have seen a similar issue before where the IMA SDK was double-requesting a VAST ad tag on local servers.  This is expected behavior and we noticed that in the console, the following was getting returned:
Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true.

Can you please check your logs and console to make sure that no errors, specifically to CORS are being returned.

You are receiving the error, Error loading ads: Unable to request ads from server due to network error because your VAST has to be DFP or AdSense hosted.  I will speak to the rest of the team to see if there is anything that we can do on our end, but because it is a serving issue, various other serving parameters from DFP might be involved that are otherwise dormant when requesting ads offline resulting in the error you reported.

Thanks,
Tyler Sidell
IMA SDK Team

Goldy Lamont

unread,
Oct 26, 2015, 5:27:44 PM10/26/15
to Interactive Media Ads SDK
Thanks Tyler for helping out. No I am not getting any CORS errors in my console. I have actually tested in 3 different XCode projects and I never saw any CORS errors, just the general network error or an error saying that the ad couldn't play. 

When you mention there that the VAST has to be DFP or AdSense hosted--do you mean that you block requests unless the URL matches up to a specific list of predefined ad servers? I actually am using a DFP called LQKD in this case--my server is simply a proxy in-between which unfortunately is a requirement for this project. If there's any headers or anything that I should be passing back along with my VAST tag I could do this...

In your opinion, is it better that I just don't use the Google player in this situation? I am also wondering if perhaps I wasn't in dev and was talking to our public api server (not launched yet) if this would work. Any light you can shed as to what the iOS player will accept as valid is appreciated.

Tyler Sidell (IMA SDK Team)

unread,
Oct 27, 2015, 9:59:29 AM10/27/15
to Interactive Media Ads SDK
Hi Goldy,

You shouldn't have a problem using the Google player in this situation.  In fact, this sounds like it is more of a server-side issue and I would check the server where you are hosting the VAST tag.  The error you are receiving is because the SDK cannot communicate with the server where the tag is hosted.  You are facing a network error and this should work when you move to a public server.  

Glad to hear that it isn't a CORS issue.  That was related to the issue that we were seeing where the request was returning two ads requests.  

You don't necessarily have to have to use DFP or AdSense.  You can use any VAST-compliant ad server with the SDK.  However, since your VAST tag is hosted locally there is an issue reaching that server from your implementation.  Can you try making the VAST tag global to see if that fixes the issue?  You can share the tag with us if you would like but we believe the issue lies more on the server side.

Thanks,
Tyler Sidell
IMA SDK Team

Goldy Lamont

unread,
Oct 27, 2015, 1:42:52 PM10/27/15
to Interactive Media Ads SDK

Tyler, I have to respectfully disagree with you about the issue — the error I’m receiving is communicating with my server. I have definitely verified this, and I have verified that my server is responding back with the correct VAST xml tags. I have also confirmed that using only the Google player that it sends two (2) requests to my server and receives back two tags. The error message is misleading and is incorrect. There is definitely communication going on and I’ve verified what’s being returned. I’ve also tested out the server/tags with JWPlayer and Veeso player and they work for these mobile SDKs. But at the end of the day I like the Google IMA player because it is lightweight and would love to get it to work in my app. 


The error I’m seeing is that my server is being asked for two ad requests but then Google player says there was a general network error. I don’t see anything mentioned about CORS specifically, yet the error returned to me is obviously wrong since not only is my server communicating but it’s sending two requests back to the player. 


If this is out of scope for you guys then I understand, but if you have any other suggestions for how I can troubleshoot or anything I can try I would love to follow up. I've done a good amount of due diligence including testing my server and tags out on other media players successfully side by side next to Google's iOS SDK.


I've been testing using this Google sample VAST tag:


http://pubads.g.doubleclick.net/gampad/ads?sz=640x360&iu=/6062/iab_vast_samples/skippable&ciu_szs=300x250,728x90&impl=s&gdfp_req=1&env=vp&output=xml_vast2&unviewed_position_start=1&url=[referrer_url]&correlator=[timestamp]


Thanks!

Goldy Lamont

unread,
Oct 27, 2015, 1:47:36 PM10/27/15
to Interactive Media Ads SDK

Tyler Sidell (IMA SDK Team)

unread,
Oct 27, 2015, 4:44:19 PM10/27/15
to Interactive Media Ads SDK
Hi Goldy,

I may have misinterpreted your particular use case.  To gather a bit more information about this use case:
  • Are you also experiencing the same error message when implementing our sample examples?  
  • Also, does this particular error affect ad playback in your implementation?  You might be experiencing double requests due to the proxy that you are using.  We have seen this in the past as you aren't connecting to the DFP server directly.
In the meantime, I'll relay the concern about the error message to the rest of the team and provide you with any updates along with additional information.   

Thanks,
Tyler Sidell
IMA SDK Team

Kamal Hood

unread,
Oct 29, 2015, 4:25:38 PM10/29/15
to ima...@googlegroups.com
Yes I do see the same error. I’ve tried substituting the ad tag in both the sample examples you provide, and also from a new blank project I built from scratch and then imported in GoogleAds-IMA-iOS-SDK. I actually have about three different projects importing this library/framework where I was testing—I wanted to see how to integrate manually, using CocoaPods, and also just using the “sample examples” directly. 

Something that would help me understand tremendously—could you explain just a bit more regarding this quote:  "We have seen this in the past as you aren't connecting to the DFP server directly.” << Does the Google SDK purposefully filter out certain URLs so that they don’t work? I’m not sure if you are saying:

  • Google SDK **does** work for a correctly configured dev server giving out properly formed VAST tags. If you are getting back two properly formed VAST tags per request by Google SDK and it still throws an error then your dev server is configured wrong, because it should work.
  • The SDK was built specifically **not** to work with all URLs, and actively blocks requests that don’t meet some internal filter we have setup
  • We aren’t really sure. We haven’t tested really using a local dev vast tag server

Thanks for the follow up so far! I do like the coding and usage of delegates. And also the library is lightweight which makes it an attractive option, not to mention its integration with Google ad tags, etc.


--
You received this message because you are subscribed to a topic in the Google Groups "Interactive Media Ads SDK" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ima-sdk/oesw7tMutFk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ima-sdk+u...@googlegroups.com.
To post to this group, send email to ima...@googlegroups.com.
Visit this group at http://groups.google.com/group/ima-sdk.
For more options, visit https://groups.google.com/d/optout.

Tyler Sidell (IMA SDK Team)

unread,
Oct 29, 2015, 4:50:40 PM10/29/15
to Interactive Media Ads SDK
Hi Kamal,

Thanks for reaching out and apologies for the confusion. The issue that I was referring to in the following statement, "We have seen this in the past as you aren't connecting to the DFP server directly", was in reference to the double requests that were getting sent. 

The issue ended up being related to CORS. The first ad request is failing because the SDK is using a wildcard Access-Control-Allow-Origin with the credentials flag. When this first request fails, it asks for it again without the credentials flag which works. The user set the Access-Control-Allow-Origin wildcard to "http://imasdk.googleapis.com" and it resolved the issue.  The SDK does not filter out URLs.

Cheers,
Tyler Sidell
IMA SDK Team

Goldy Lamont

unread,
Oct 29, 2015, 5:46:12 PM10/29/15
to Interactive Media Ads SDK
Thank you! I think the issue was with the CORS response my server was giving and that the Google SDK was failing, with an error but a non-descriptive error saying it couldn't connect. My server was sending back two positive responses but the SDK was throwing an error I suppose because I wasn't setting all the CORS headers correctly? in any case I can see commercials in the video player now routed through my local dev server. I did use a wildcard for CORS however will review my implementation before going to production. Good grief it feels great to see this working! Tyler I would have never known to look at CORS as an issue without you mentioning it and also mentioning specifically Access-Control-Allow-Origin. Perhaps this could be added to documentation somewhere as a requirement for the VAST tag response (that proper CORS headers are configured)? 

For others below are headers my local dev server are sending back in the response which seem to work for me--again I will review this before going to production to see if I can tighten security and to ensure it works live:

Access-Control-Allow-Credentials → true
Access-Control-Allow-Headers → Origin, Authorization, Accept, Content-Type
Access-Control-Allow-Methods → POST, GET, OPTIONS, PUT, DELETE
Access-Control-Allow-Origin → *
Access-Control-Max-Age → 1728000
Cache-Control → max-age=0, private, must-revalidate
Content-Type → text/xml; charset=utf-8
ETag → W/"2ded643876a55589f0ef72c247155c09"
Transfer-Encoding → chunked
X-Content-Type-Options → nosniff
X-Frame-Options → SAMEORIGIN
X-Request-Id → b48f62ed-c947-4521-a846-0f9d2d232f66
X-Runtime → 2.669267
X-XSS-Protection → 1; mode=block

Tyler Sidell (IMA SDK Team)

unread,
Oct 30, 2015, 9:47:23 AM10/30/15
to Interactive Media Ads SDK
Hi Goldy,

That is great news! I'm glad that we were able to get this configured properly. Although we do have some documentation pertaining to setting up CORS correctly, I will bring these details back to the rest of the team to see if there are any changes that we can make pertaining to the documentation surrounding this configuration.

Thanks,
Tyler Sidell
IMA SDK Team

Goldy Lamont

unread,
Oct 30, 2015, 2:24:29 PM10/30/15
to Interactive Media Ads SDK
Tyler, I just found the CORS documentation I believe you were mentioning:

^^ towards the bottom under Advanced Topics

Wanted to post it here for other users. 

I was doing some thinking on ways this would have been less confusing for me. And with what I know now, I can see that your team has the requirement of CORS already available (thank you). Really, I think the biggest thing that would have helped me would have been a more descriptive and correct error message. It would have been great to see an error like "Could not complete ad request. CORS headers are a requirement..." or something similar. I would have immediately searched for CORS errors and Google IMA SDK and found the documentation you already provided. With this insight I think I could have figured it out on my own without bugging you guys :-) Thanks again for the help. Let me know if you'd like me to test anything out.
Reply all
Reply to author
Forward
0 new messages