Uploaded image for project: 'Nuxeo Mobile'
  1. Nuxeo Mobile
  2. NXMOB-290

Better track Nuxeo server connection errors

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: iOS 1.7, Android 1.4
    • Component/s: Android, iOS

      Description

      Let's notify Bugsnag when catching an error in:

      async function tryConnection(url) {
        try {
          const res = await fetch(url, { method: 'HEAD' });
          if (res.status === 200) {
            // always return the URL from the response in case of redirects
            return nuxeoUtils.getServerURL(res.url);
          }
        } catch (e) {
          return null;
        }
        return null;
      }
      

      Moreover, on Android, we need a way to track the underlying Java error, typically in case of an SSL error. On a server with a bad certificate, the only stack trace we get is:

      index.android.bundle?platform=android&dev=true&hot=true&minify=false:90037 TypeError: Network request failed
          at XMLHttpRequest.xhr.onerror (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:30441:8)
          at XMLHttpRequest.dispatchEvent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:15513:15)
          at XMLHttpRequest.setReadyState (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:32637:6)
          at XMLHttpRequest.__didCompleteResponse (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:32473:6)
          at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:32577:52
          at RCTDeviceEventEmitter.emit (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:14614:23)
          at MessageQueue.__callFunction (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:12419:34)
          at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:12291:7
          at guard (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:12229:1)
          at MessageQueue.callFunctionReturnFlushedQueue (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:12290:1)
      

      When using java.net.HttpURLConnection to perform the HEAD request we can have the undelying Java stack trace:

      02-08 13:20:02.904  2572  2607 D mobile  : javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:328)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.okhttp.internal.http.SocketConnector.connectTls(SocketConnector.java:103)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.okhttp.Connection.connect(Connection.java:143)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:185)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:341)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:437)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:388)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:501)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.nuxeomobile.RNHttpsUrlConnection.fetch(RNHttpsUrlConnection.java:44)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at java.lang.reflect.Method.invoke(Native Method)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:318)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at android.os.Handler.handleCallback(Handler.java:739)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at android.os.Handler.dispatchMessage(Handler.java:95)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at android.os.Looper.loop(Looper.java:148)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at java.lang.Thread.run(Thread.java:818)
      02-08 13:20:02.904  2572  2607 D mobile  : Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:324)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:225)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:115)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:556)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
      02-08 13:20:02.904  2572  2607 D mobile  : 	at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:324)
      02-08 13:20:02.904  2572  2607 D mobile  : 	... 23 more
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: