Home > front end >  Admob in flutter app: "Error while connecting to ad server: SSL handshake aborted"
Admob in flutter app: "Error while connecting to ad server: SSL handshake aborted"

Time:03-06

I'm getting SSL handshake error in Admob flutter when trying to load Rewarded interstitial ads (test unit ad id on a real hardware):

Error while connecting to ad server: SSL handshake aborted: ssl=0x72ea901888: I/O error during system call, Connection reset

I do understand what it means, but i believe it's reliable enough on back-end side and i wonder if i did anything wrong.

main.dart:

...
await MobileAds.instance.initialize();
...

page.dart:

RewardedInterstitialAd? _rewardedInterstitialAd;
int _numRewardedInterstitialLoadAttempts = 0;
int maxFailedLoadAttempts = 3;
VoidCallback? _adsCallback;
...
const ADMOB_TEST_REWARDED_INTERSTITIAL_AD_UNIT_ID = "ca-app-pub-3940256099942544/5354046379";
...
String getAdmobRewardedInterstitialUnitId() {
  return kDebugMode
      ? ADMOB_TEST_REWARDED_INTERSTITIAL_AD_UNIT_ID
      : ADMOB_REWARDED_INTERSTITIAL_AD_UNIT_ID;
}
...
AdRequest createAdRequest() => AdRequest(
  keywords: <String>[
    'keyword1',
    ...
  ],
  contentUrl: 'http://myappdomain.app',
  nonPersonalizedAds: true,
);
...
void createRewardedInterstitialAd(VoidCallback adsCallback) {
  _adsCallback = adsCallback;

  FirebaseCrashlytics.instance.log('RewardedInterstitialAd.load()');
  RewardedInterstitialAd.load(
      adUnitId: getAdmobRewardedInterstitialUnitId(),
      request: createAdRequest(),
      rewardedInterstitialAdLoadCallback: RewardedInterstitialAdLoadCallback(
        onAdLoaded: (RewardedInterstitialAd ad) {
          print('$ad loaded.');
          FirebaseCrashlytics.instance.log('RewardedInterstitialAd: onl oaded()');

          _rewardedInterstitialAd = ad;
          _numRewardedInterstitialLoadAttempts = 0;
        },
        onAdFailedToLoad: (LoadAdError error) {
          print('RewardedInterstitialAd failed to load: $error');
          FirebaseCrashlytics.instance.log('RewardedInterstitialAd: onAdFailedToLoad');
          FirebaseCrashlytics.instance.recordError(error, StackTrace.empty);

          _rewardedInterstitialAd = null;
          _numRewardedInterstitialLoadAttempts  = 1;
          if (_numRewardedInterstitialLoadAttempts < maxFailedLoadAttempts) {
            createRewardedInterstitialAd(adsCallback);
          }
        },
      ));
}

AndroidManifest.xml:

...
       <!-- test -->
       <meta-data
           android:name="com.google.android.gms.ads.APPLICATION_ID"
           android:value="ca-app-pub-3940256099942544~3347511713"/>
    </application> 

Here is what i get:

2022-03-02 11:35:32.974 I/flutter: RewardedInterstitialAd failed to load: LoadAdError(code: 0, domain: com.google.android.gms.ads, message: Error while connecting to ad server: SSL handshake aborted: ssl=0x72ea901888: I/O error during system call, Connection reset by peer, responseInfo: ResponseInfo(responseId: null, mediationAdapterClassName: , adapterResponses: []))

The date/time on the device is ok. What could be the reason?

PS. google_mobile_ads: ^1.1.0

PPS. I can see that Rewarded Interstitial is in beta in 1.1.0, probably that's a bug.

PPPS. I've enabled ads tracing in my Google account and got this in the log:

2022-03-03 11:10:21.597 V/NativeCrypto: SSL handshake aborted: ssl=0x72d8ecf348: I/O error during system call, Connection reset by peer
2022-03-03 11:10:21.600 E/GoogleConversionReporter: Error sending ping
    javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0x72d8ecf348: I/O error during system call, Connection reset by peer
        at com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
        at com.google.android.gms.org.conscrypt.NativeSsl.doHandshake(:com.google.android.gms@[email protected] (100400-428111784):6)
        at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(:com.google.android.gms@[email protected] (100400-428111784):16)
        at com.android.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:196)
        at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:153)
        at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:116)
        at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:186)
        at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128)
        at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289)
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:542)
        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:106)
        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:30)
        at drb.run(PG:14)

Note i'm having network config file referenced from AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
</network-security-config>

Here was the request:

2022-03-03 11:18:28.804 I/Ads: GMA Debug BEGIN
2022-03-03 11:18:28.804 I/Ads: GMA Debug CONTENT {"timestamp":1646288308803,"event":"onNetworkRequest","components":["network_request_0864d36d-6153-46ad-94aa-d4c40db7d2fe"],"params":{"firstline":{"uri":"https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.html","verb":"GET"},"headers":[{"name":"User-Agent","value":"Mozilla/5.0 (Linux; Android 10; Mi 9T Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/98.0.4758.101 Mobile Safari/537.36 (Mobile; afma-sdk-a-v214106999.212910000.1)"},{"name":"Accept","value":"text/html,application/xhtml xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"},{"name":"Upgrade-Insecure-Requests","value":"1"}]}}
2022-03-03 11:18:28.804 I/Ads: GMA Debug FINISH

I've checked "https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html" and i can't also connect to it from my desktop due to SSL issue.

CodePudding user response:

It does not work even in example app with the same error, a ticket created.

  • Related