The request timed out


#1

I’m trying to integrate mopub in one of my apps and I started seeing one really weird issue. Then I decided to download the sample mopub app ( https://dev.twitter.com/mopub-demand/overview/self-testing-your-creatives ) to see if the same issue was also happening.

It turned out that the issue is happening even on the sample mopub app.

While I’m connected to the wifi, the ads are loaded just fine, but as soon as I switch to 4G/3G, I start getting “The request timed out”.

After further investigation, I could isolate this issue to one specific Brazilian carrier: VIVO which is the major cellular carrier in Brazil.

Is there anybody seeing the same issue? Any ideas how to workaround this?

BTW: the mopub support stopped responding to my emails about this issue.

Some Logs:

Nov 5 18:06:08 Paulo-Venturi MoPubSampleApp[1819] : MOPUB: Banner view (bca65d9e7fe64b50b8cc82b2ec47fb62) loading ad with MoPub server URL: http://ads.mopub.com/m/ad?v=8&udid=ifa:XXXX&id=bca65d9e7fe64b50b8cc82b2ec47fb62&nv=3.2.0&o=p&sc=2.0&z=-0200&mr=1&ct=3&av=1.0&cn=VIVO&iso=br&mnc=06&mcc=724&dn=iPhone6%2C2&ts=1
Nov 5 18:06:18 Paulo-Venturi MoPubSampleApp[1819] : MOPUB: Banner view (bca65d9e7fe64b50b8cc82b2ec47fb62) failed. Error: Error Domain=NSURLErrorDomain Code=-1001 “The request timed out.” UserInfo=0x1700ee680 {NSUnderlyingError=0x17424c2d0 “The request timed out.”, NSErrorFailingURLStringKey=http://ads.mopub.com/m/ad?v=8&udid=ifa:XXXX&id=bca65d9e7fe64b50b8cc82b2ec47fb62&nv=3.2.0&o=p&sc=2.0&z=-0200&mr=1&ct=3&av=1.0&cn=VIVO&iso=br&mnc=06&mcc=724&dn=iPhone6%2C2&ts=1, NSErrorFailingURLKey=http://ads.mopub.com/m/ad?v=8&udid=ifa:XXXX&id=bca65d9e7fe64b50b8cc82b2ec47fb62&nv=3.2.0&o=p&sc=2.0&z=-0200&mr=1&ct=3&av=1.0&cn=VIVO&iso=br&mnc=06&mcc=724&dn=iPhone6%2C2&ts=1, NSLocalizedDescription=The request timed out.}


#2

Sorry to hear you are having issues in Brazil. The folks from the MoPub team may have some more specifics via support@mopub.com

Having said that you could perform some network checks on adLoad. Here is a sample ViewController:

  import UIKit
  import MoPub

  class ViewController: UIViewController
  , MPAdViewDelegate
  {

      // TODO: Replace this test id with your personal ad unit id
      var adView: MPAdView = MPAdView(adUnitId: "AD_UNIT_ID", size: MOPUB_BANNER_SIZE)

      override func viewDidLoad() {
          super.viewDidLoad()
          self.adView.delegate = self
          self.adView.frame = CGRectMake(0, self.view.bounds.size.height - MOPUB_BANNER_SIZE.height,
              MOPUB_BANNER_SIZE.width, MOPUB_BANNER_SIZE.height)
          self.view.addSubview(self.adView)
          self.loadAdIfReachable()
      }

      func loadAdIfReachable(){
          if Network.isConnected() {
              // Network is connected ...
              self.adView.loadAd()
          } else {
              // No network -- do something truly amazing...
          }
      }

      func adViewDidFailToLoadAd(view: MPAdView!) {
          // ISSUE
          // There is still an issue loading the ads e.g. Timeout Error....
          println(Network.carrier())
          println(Network.isConnected())
          println(Network.isReachable())
      }

      func viewControllerForPresentingModalView() -> UIViewController {
          return self
      }

  }

Putting this together very quickly you could perform some Network specifics e.g.

  import Foundation
  import CoreTelephony
  import SystemConfiguration

  public class Network {

      class func carrier() -> String{
          var carrier = CTCarrier().carrierName
          if carrier == nil {
              carrier = "No Carrier"
          }
          return carrier
      }

      class func isReachable() -> Bool {
          let reachabilityFlags:SCNetworkReachabilityFlags = SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsReachable)
          if 0 != reachabilityFlags & SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsReachable) {
              return true
          }
          return false
      }

      class func isConnected() -> Bool {
          var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
          zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress))
          zeroAddress.sin_family = sa_family_t(AF_INET)

          let defaultRouteReachability = withUnsafePointer(&zeroAddress) {
              SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0)).takeRetainedValue()
          }

          var flags: SCNetworkReachabilityFlags = 0
          if SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags) == 0 {
              return false
          }

          let isReachable = (flags & UInt32(kSCNetworkFlagsReachable)) != 0
          let needsConnection = (flags & UInt32(kSCNetworkFlagsConnectionRequired)) != 0

          return (isReachable && !needsConnection) ? true : false
      }
      
  }

Hope this makees some sense. It would be great to see the output from Network specifically isConnected() and isReachable() when the ad fails to load.


#3

Hello Everyone,

There was previously an issue with users using the ISPs Embratel, Vivo, and Net Servicos de Comunicacao not being able to connect to the mopub.com domain. This issue is now resolved. If there are any further issues or if this arises again, please contact support@mopub.com to report the issue.

Thanks,
Edward