颤动应用中的 Admob:"Error while connecting to ad server: SSL handshake aborted"

Admob in flutter app: "Error while connecting to ad server: SSL handshake aborted"

我在 Admob flutter 中尝试加载奖励插页式广告(在真实硬件上测试单元广告 ID)时遇到 SSL 握手错误:

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

我明白这意味着什么,但我相信它在后端方面足够可靠,我想知道我是否做错了什么。

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: onLoaded()');

          _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> 

这是我得到的:

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: []))

设备上的date/time没问题。 可能是什么原因?

PS。 google_mobile_ads: ^1.1.0

PPS。我可以 see 奖励插页式广告在 1.1.0 中处于测试阶段,这可能是一个错误。

PPPS。我在我的 Google 帐户中启用了广告跟踪并在日志中得到了这个:

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@220221028@22.02.21 (100400-428111784):6)
        at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(:com.google.android.gms@220221028@22.02.21 (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)

注意我有从 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>

请求如下:

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

我检查了“https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html”,但由于 SSL 问题,我也无法从桌面连接到它。

即使在 example app with the same error, a ticket 创建时也不起作用。