[ANDROID] Loading ads from local server

534 views
Skip to first unread message

Leo

unread,
Dec 7, 2016, 5:21:40 AM12/7/16
to Interactive Media Ads SDK
Hello!

I'm trying to play video ads based on VAST xml stored on my local server. To be exact, on runtime, I start local HTTP server and place custom master.xml file on it. Then I pass 127.0.0.1/master.xml link to AdsRequest.setAdTagUrl().

But this does not work because master.xml is requested not locally (as I expected), but from Google server:
GET http://127.0.0.1:8080/master.xml HTTP/1.1
Host: 127.0.0.1:8080
Proxy-Connection: keep-alive
Origin: http://imasdk.googleapis.com
x-wap-profile: http://218.249.47.94/Xianghe/MTK_Phone_KK_UAprofile.xml
User-Agent: Mozilla/5.0 (Linux; Android 4.4.2; Lenovo A5500-H Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Safari/537.36
Accept: */*
Referer: http://imasdk.googleapis.com/native/sdkloader/native_sdk_v3.html?sdk_version=a.3.1.3&hl=ru&wvr=2&app=com.myapp.app
Accept-Encoding: gzip,deflate
X-Requested-With: com.myapp.app

This obviously fails. Why SDK runs this request through Google server? Is there some way to make it request it locally? Storing this xml on public server is not an option unfortunately.

IMA SDK version 3.1.3.

Thank you.

Vu Chau (IMA SDK Team)

unread,
Dec 7, 2016, 10:12:39 AM12/7/16
to Interactive Media Ads SDK
Hi Leo,

The fields on that request header shows the necessary IMA components to be fetched at runtime (e.g. http://imasdk.googleapis.com/native/sdkloader/native_sdk_v3.html). It does not indicate that the SDK makes a live request for your local resources.

I suggest looking into properly setting your cross-origin resource sharing configuration on your server and see how that improves this use case. There's additional information you can find on several posts here about localhost use cases that might provide more insights.

Vu Chau
IMA SDK Team

Leo

unread,
Dec 20, 2016, 11:47:02 AM12/20/16
to Interactive Media Ads SDK
Hello Vu!

Sorry for delay with response on this thread.

As far as I understand it never gets to cors (which have been set to "*" and also to "" with no difference). Header says
that referer is imasdk server:


Afaik, this means that page located on imasdk.googleapis.com made the request to my local server.

Best regards, Lev

Leo

unread,
Dec 20, 2016, 11:50:09 AM12/20/16
to Interactive Media Ads SDK
Sorry, mistyped:

I have tried setting cors to "*" and to "http://imasdk.googleapis.com" on my server.

Best regards, Lev

Chris Feldman (IMA SDK Team)

unread,
Dec 20, 2016, 5:22:03 PM12/20/16
to Interactive Media Ads SDK
Hi Leo,

Vu is out of the office so I will be taking over your case.

We were able to reproduce your issue after setting up an Apache localhost server. The issue is connected to the CORS configuration of the server and is unrelated to the SDK itself. We'll continue to investigate the issue, but as it is a niche use case there may not be much we can do.

I will suggest trying other means of hosting your VAST response. You could, for example, host the VAST xml file with a GitHub pages link. Pages should allow you to link directly to your VAST without going through localhost.

Regards,
Chris Feldman
IMA SDK Team

Vu Chau (IMA SDK Team)

unread,
Dec 20, 2016, 10:46:05 PM12/20/16
to Interactive Media Ads SDK
Hi Leo,

I tested with an IIS localhost on a Windows machine, and after I enabled CORS in IIS, I am able to request my local ad tag from my Android emulator. Note that you will need to use 10.0.2.2 as opposed to 127.0.0.1 for the URL to your ad tag. 

Since this boils down to a server administration inquiry, setting up CORS differs from server to server. We won't be able to provide steps for all servers, and while some might be easier than others, enabling CORS should be the way to go. While this won't affect IMA in particular, make sure you are selective with the origin you pass in (i.e. don't use a wildcard), due to security best practices.

Let me know if you have any questions,

Vu Chau
IMA SDK Team
Reply all
Reply to author
Forward
0 new messages