Flakey connection to dev machine - ios

My app calls to my dev machine over the local network to get some data. Usually this work fine, but sometimes it won't connect and times out. When this happens, I can copy and paste from the output window the URL its requested and paste it into a browser on a different system, and the request works fine.
After a while, the app will connect fine without any changes on my part.
Does anyone have any ideas why this might happen?
Sometimes, I get this message to the output window...
> 2017-01-19 16:35:28.427179 MyApp[489:69535] [] nw_socket_connect
> connectx failed: [64] Host is down 2017-01-19 16:35:28.817530
> MyApp[489:69426] PromiseKit: unhandled error: Error
> Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server."
> UserInfo={NSUnderlyingError=0x1702428b0 {Error
> Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)"
> UserInfo={_kCFStreamErrorCodeKey=64, _kCFStreamErrorDomainKey=1}},
> NSErrorFailingURLStringKey=http://192.168.8.52:45455/api/hello,
> NSErrorFailingURLKey=http://192.168.8.52:45455/api/hello,
> _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=64, NSLocalizedDescription=Could not connect to the server.}

Related

How to silence debug logging with Alamofire (or NSUrlSession)?

Xcode 12.2,
Alamofire 5.4.0,
Swift 5
I have this snippet of code to request data from a backend which works fine in the happy flow.
But if for some reason the backend is unreachable, I see autogenerated logging I want it to hide or silence. Because it's disturbing me when I'm analysing debug logging.
let request = AF.request("http://192.168.1.5:44444/api/users", headers: headers)
request.responseJSON { (data) in
switch data.result {
case .success:
print("Request Succes!")
case .failure(let errorData):
print("Request Failed")
print("\(errorData.errorDescription ?? "")")
}
}
Error output:
Task <xxxxxxxx>.<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:61])
Task <xxxxxxxx>.<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x600000d82250 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <xxxxxxxxx>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <xxxxxxxxx>.<1>"
), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=http://192.168.1.5:44444/developer, NSErrorFailingURLKey=http://192.168.1.5:44444/developer, _kCFStreamErrorDomainKey=1}
Request Failed
URLSessionTask failed with error: Could not connect to the server.
I want to get rid of the following, which is not generated by me:
Task <xxxxxxxx>.<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:61])
Task <xxxxxxxx>.<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x600000d82250 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <xxxxxxxxx>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <xxxxxxxxx>.<1>"
), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=http://192.168.1.5:44444/developer, NSErrorFailingURLKey=http://192.168.1.5:44444/developer, _kCFStreamErrorDomainKey=1}
and see only:
Request Failed
URLSessionTask failed with error: Could not connect to the server.
These are system logs produced by the OS, not Alamofire. While you can silence them by disabling the os subsystem, I don't recommend it, as that disables all os_logs in your app and other os module functionality, like signposts. A feature request to Apple using Feedback Assistant may eventually convince them to let us filter these in Xcode.
I had exactly the same issue, I want to only the the debug entries created by me and not the ones by the system. I solved this using a prefix for all my own log entries. For example "[sync] Synchronizing from server..." or "[sync] Couldn't connect to server.".
Now you can set the filter in XCode (at the bottom of the log pane) to the prefix "[sync]" and you only see your own entries. This even works while running the app and the logs come in!

Application stop suddenly and getting NSURLErrorDomain error

I am using IOS 13.3 and my application stop suddenly after 6 month.
I have checked my certificate and found no issue in certificate.
i am getting the following error.
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9816)
2020-04-17 01:38:14.778140+0530 Example[38000:704335] Task <71350D43-9801-46F2-9F9E-333AF09964CE>.<1> HTTP load failed (error code: -1200 [3:-9816])
2020-04-17 01:38:14.779009+0530 Example[38000:704332] Task <71350D43-9801-46F2-9F9E-333AF09964CE>.<1> finished with error - code: -1200
2020-04-17 01:38:14.782985+0530 Example[38000:704332] Task <71350D43-9801-46F2-9F9E-333AF09964CE>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSErrorFailingURLStringKey=https://api.example.com:1410/v1.1/users/signin, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, kCFStreamErrorDomainKey=3, NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <71350D43-9801-46F2-9F9E-333AF09964CE>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <71350D43-9801-46F2-9F9E-333AF09964CE>.<1>"
), NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://api.example.com:1410/v1.1/users/signin, NSUnderlyingError=0x600002db3d50 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFNetworkCFStreamSSLErrorOriginalValue=-9816, kCFStreamErrorDomainKey=3, kCFStreamErrorCodeKey=-9816}}, kCFStreamErrorCodeKey=-9816} [-1200]
Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made.
Here is the screenshot
I'm not sure how to solve it. Any ideas?
You probably need to reconfigure your SSL certificates. I know for TCP/TLS at least, with iOS 13 they imposed more restrictions on the certificates. I created a package to handle sockets on iOS - I also included a lot of good info about making certificates how you need to now.
https://github.com/eamonwhiter73/IOSObjCWebSockets/tree/master

Firebase Connection error when date changed on device

I have setup my app's database on firebase. The app fetches data normally,
but when I change the date on device to 25th march,2019 or after that, it starts show error on console as below. Current date is 14th November, 2018.
Is there any kind of validation on firebase server.
[Firebase/InstanceID][I-IID003009] Failed to fetch default token Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSUnderlyingError=0x17025c0e0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://device-provisioning.googleapis.com/checkin, NSErrorFailingURLKey=https://device-provisioning.googleapis.com/checkin, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.}
CFNetwork SSLHandshake failed (-9807)
By setting the date too far into the future you are preventing the SSL handshake from completing successfully.
The status code of -9807 indicates that something in the certificate chain is invalid; It is likely that a certificate in the chain expires before the 25th of March 2019. Because a certificate has expired, an SSL connection cannot be made.

While using 3G internet connection, Crashlytics gives no internet connection error for event uploading

I am using Fabric/Crashlytics SDK on my iOS application (version Crashlytics 3.10.7). When I use 3G internet connection (connection exists I tested) and debug the app, I have realized Crashlytics logs on Xcode (10.0) console. Although there is internet, it says there is an error on LocalUploadTask for uploading crashlytics events to the url Logs are below in detail:
2018-09-26 09:39:07.153257+0300 xxx[9164:1662764] Task <81F06DC0-348D-431F-B209-DE3E666BE2EE>.<129> load failed with error Error Domain=NSURLErrorDomain Code=-1009 "İnternet bağlantısı çevrimdışı gözüküyor." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x283715590 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <81F06DC0-348D-431F-B209-DE3E666BE2EE>.<129>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalUploadTask <81F06DC0-348D-431F-B209-DE3E666BE2EE>.<129>"), NSLocalizedDescription=İnternet bağlantısı çevrimdışı gözüküyor., NSErrorFailingURLStringKey=https://e.crashlytics.com/spi/v2/events, NSErrorFailingURLKey=https://e.crashlytics.com/spi/v2/events, _kCFStreamErrorDomainKey=1} [-1009]
But when I try it on wifi connection there is no such an error. Is there any problem here today or any bug on this version?
using:
Xcode 10.0
App deployment target min 10.0
Crashlytics 3.10.7
Answers 1.3.7

AWS AWSiOSSDKv2 DynamoDB Error

This has been working fine for over a year and then:
Error occurred: [Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={NSUnderlyingError=0x61000004c300 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=832912, _kCFStreamErrorDomainKey=0}}, NSErrorFailingURLStringKey=https://dynamodb.us-east-1.amazonaws.com/, NSErrorFailingURLKey=https://dynamodb.us-east-1.amazonaws.com/, _kCFStreamErrorDomainKey=0, _kCFStreamErrorCodeKey=832912, NSLocalizedDescription=A server with the specified hostname could not be found.}]
Is Amazon just down today? The "healthy" status shows that it is up.

Resources