{"action":"created","issue":{"url":"https://api.github.com/repos/matomo-org/piwik-sdk-android/issues/199","repository_url":"https://api.github.com/repos/matomo-org/piwik-sdk-android","labels_url":"https://api.github.com/repos/matomo-org/piwik-sdk-android/issues/199/labels{/name}","comments_url":"https://api.github.com/repos/matomo-org/piwik-sdk-android/issues/199/comments","events_url":"https://api.github.com/repos/matomo-org/piwik-sdk-android/issues/199/events","html_url":"https://github.com/matomo-org/piwik-sdk-android/issues/199","id":312867256,"number":199,"title":"SDK crashes app after a while in case the tracking backend is permanently not reachable","user":{"login":"WillSarah","id":5228160,"avatar_url":"https://avatars2.githubusercontent.com/u/5228160?v=4","gravatar_id":"","url":"https://api.github.com/users/WillSarah","html_url":"https://github.com/WillSarah","followers_url":"https://api.github.com/users/WillSarah/followers","following_url":"https://api.github.com/users/WillSarah/following{/other_user}","gists_url":"https://api.github.com/users/WillSarah/gists{/gist_id}","starred_url":"https://api.github.com/users/WillSarah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WillSarah/subscriptions","organizations_url":"https://api.github.com/users/WillSarah/orgs","repos_url":"https://api.github.com/users/WillSarah/repos","events_url":"https://api.github.com/users/WillSarah/events{/privacy}","received_events_url":"https://api.github.com/users/WillSarah/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-04-10T10:40:41Z","updated_at":"2018-04-11T08:42:25Z","closed_at":null,"author_association":"NONE","body":"We are currently using the Piwik SDK in one client app. Last week the staging environment was undergoing maintenance and was not reachable for a few days / returning HTTP 500 error codes for every call made by the Piwik SDK.\r\n\r\nIt seems that the SDK then retries the calls without a retry limit until the app crashes with a SSLException \"Unable to create application data\", which seems to indicate a resource exhaustion due to too many threads/files etc. (At least according to [this](https://github.com/square/okhttp/issues/3761) issue in the OkHttp repo). This behaviour was logged with the version 2.0.0 of the Piwik SDK integrated, but could also be reproduced with the 3.0.0 version of the Piwik SDK.\r\n\r\nIn the described case, the SDK always retries the calls without a retry limit, indicated by the endlessly repeating logs like this:\r\n\r\n```\r\n04-04 17:23:19.183 18907-18946/? D/PIWIK:EventCache: Switched state to ONLINE, uncached 0 events from disk.\r\n04-04 17:23:19.184 18907-18946/? D/PIWIK:Dispatcher: Drained 1 events.\r\n04-04 17:23:19.351 18907-18946/? D/PIWIK:DefaultPacketSender: status code 500\r\n04-04 17:23:19.358 18907-18946/? D/PIWIK:Dispatcher: Unsuccesful assuming OFFLINE, requeuing events.\r\n04-04 17:23:19.360 18907-18946/? D/PIWIK:Dispatcher: Dispatched 0 events.\r\n04-04 17:23:19.364 18907-18946/? D/PIWIK:EventDiskCache: Cache check took 0ms\r\n04-04 17:23:19.365 18907-18946/? D/PIWIK:EventDiskCache: Uncaching of 0 events took 0ms\r\n04-04 17:23:19.365 18907-18946/? D/PIWIK:EventCache: Switched state to ONLINE, uncached 0 events from disk.\r\n```\r\n\r\nAfter a while multiple SocketExceptions appear in the logs:\r\n```\r\n04-04 13:44:47.387 30360-30405/? D/PIWIK:EventCache: Switched state to ONLINE, uncached 0 events from disk.\r\n04-04 13:44:47.387 30360-30405/? D/PIWIK:Dispatcher: Drained 2 events.\r\n04-04 13:44:47.389 30360-30405/? D/PIWIK:Dispatcher: java.net.SocketException: socket already closed\r\n        at java.net.PlainSocketImpl.socketClose0(PlainSocketImpl.java:211)\r\n        at java.net.AbstractPlainSocketImpl.socketClose(AbstractPlainSocketImpl.java:721)\r\n        at java.net.AbstractPlainSocketImpl.close(AbstractPlainSocketImpl.java:546)\r\n        at java.net.SocksSocketImpl.close(SocksSocketImpl.java:554)\r\n        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:375)\r\n        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)\r\n        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)\r\n        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:357)\r\n        at java.net.Socket.connect(Socket.java:616)\r\n        at com.android.okhttp.internal.Platform.connectSocket(Platform.java:145)\r\n        at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:141)\r\n        at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:112)\r\n        at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184)\r\n        at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)\r\n        at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)\r\n        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)\r\n        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)\r\n        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461)\r\n        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:127)\r\n        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:258)\r\n        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)\r\n        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(Unknown Source:0)\r\n        at org.piwik.sdk.dispatcher.Dispatcher.dispatch(Dispatcher.java:247)\r\n        at org.piwik.sdk.dispatcher.Dispatcher$1.run(Dispatcher.java:167)\r\n        at java.lang.Thread.run(Thread.java:764)\r\n    Unsuccesful assuming OFFLINE, requeuing events.\r\n    Dispatched 0 events.\r\n04-04 13:44:47.391 30360-30405/? D/PIWIK:EventDiskCache: Cache check took 0ms\r\n    Uncaching of 0 events took 0ms\r\n```\r\n\r\nAfter a few minutes, the app then crashes with the following exception, preceded by \"AppData::create pipe (2) failed: Too many open files\":\r\n```\r\n04-04 14:56:58.513 5634-5697/? E/NativeCrypto: AppData::create pipe(2) failed: Too many open files\r\n04-04 14:56:58.532 5634-5697/? E/AndroidRuntime: FATAL EXCEPTION: Thread-5\r\n    Process: ?, PID: 5634\r\n    java.lang.RuntimeException: javax.net.ssl.SSLException: Unable to create application data\r\n        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.newSsl(ConscryptFileDescriptorSocket.java:161)\r\n        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.<init>(ConscryptFileDescriptorSocket.java:152)\r\n        at com.android.org.conscrypt.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:149)\r\n        at com.android.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:181)\r\n        at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:149)\r\n        at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:112)\r\n        at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184)\r\n        at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)\r\n        at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)\r\n        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)\r\n        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)\r\n        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461)\r\n        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:127)\r\n        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:258)\r\n        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)\r\n        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(Unknown Source:0)\r\n        at org.piwik.sdk.dispatcher.Dispatcher.dispatch(Dispatcher.java:247)\r\n        at org.piwik.sdk.dispatcher.Dispatcher$1.run(Dispatcher.java:167)\r\n        at java.lang.Thread.run(Thread.java:764)\r\n     Caused by: javax.net.ssl.SSLException: Unable to create application data\r\n        at com.android.org.conscrypt.NativeCrypto.SSL_new(Native Method)\r\n        at com.android.org.conscrypt.SslWrapper.newInstance(SslWrapper.java:58)\r\n        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.newSsl(ConscryptFileDescriptorSocket.java:159)\r\n        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.<init>(ConscryptFileDescriptorSocket.java:152) \r\n        at com.android.org.conscrypt.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:149) \r\n        at com.android.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:181) \r\n        at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:149) \r\n        at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:112) \r\n        at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184) \r\n        at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126) \r\n        at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95) \r\n        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281) \r\n        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224) \r\n        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461) \r\n        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:127) \r\n        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:258) \r\n        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218) \r\n        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(Unknown Source:0) \r\n        at org.piwik.sdk.dispatcher.Dispatcher.dispatch(Dispatcher.java:247) \r\n        at org.piwik.sdk.dispatcher.Dispatcher$1.run(Dispatcher.java:167) \r\n        at java.lang.Thread.run(Thread.java:764) \r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/matomo-org/piwik-sdk-android/issues/comments/380374980","html_url":"https://github.com/matomo-org/piwik-sdk-android/issues/199#issuecomment-380374980","issue_url":"https://api.github.com/repos/matomo-org/piwik-sdk-android/issues/199","id":380374980,"user":{"login":"WillSarah","id":5228160,"avatar_url":"https://avatars2.githubusercontent.com/u/5228160?v=4","gravatar_id":"","url":"https://api.github.com/users/WillSarah","html_url":"https://github.com/WillSarah","followers_url":"https://api.github.com/users/WillSarah/followers","following_url":"https://api.github.com/users/WillSarah/following{/other_user}","gists_url":"https://api.github.com/users/WillSarah/gists{/gist_id}","starred_url":"https://api.github.com/users/WillSarah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WillSarah/subscriptions","organizations_url":"https://api.github.com/users/WillSarah/orgs","repos_url":"https://api.github.com/users/WillSarah/repos","events_url":"https://api.github.com/users/WillSarah/events{/privacy}","received_events_url":"https://api.github.com/users/WillSarah/received_events","type":"User","site_admin":false},"created_at":"2018-04-11T08:42:25Z","updated_at":"2018-04-11T08:42:25Z","author_association":"NONE","body":"@d4rken - It seems that this indeed fixes the crashes that occured before. I tried reproducing the issue with Charles (as the backend is working now) with version 3.0.0 and did get some crashes related to the \"too many files open\" scenario (like \"java.lang.RuntimeException: Could not read input channel file descriptors from parcel\") that are not occuring with the version from dev. \r\n\r\nAlso I will try to use a dispatchTime > 0, as using 0 currently means that there is no sleep time between call retries (DefaultDispatcher:162), which leads to a ton of calls in a short time. \r\n\r\nThumbs up for a 3.0.1 version and thanks alot! "}}
{"actor":{"display_login":"WillSarah"}}