Login to Twitter sometimes fails - ios

I use the simple code for login to Twitter
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
if (session != nil) {
NSLog(#"successful %#",session);
} else {
NSLog(#"error: %#", error);
}
}];
and sometimes I get the error:
2016-08-04 15:39:14.472 MyProject[11143:132894] [TwitterKit] did
encounter error with message "Error attempting to obtain temporary
auth token.": Error Domain=NSURLErrorDomain Code=-1004 "Could not
connect to the server." UserInfo={NSUnderlyingError=0x7fe043a49830
{Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)"
UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}},
NSErrorFailingURLStringKey=https://api.twitter.com/oauth/request_token,
NSErrorFailingURLKey=https://api.twitter.com/oauth/request_token,
_kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.} 2016-08-04
15:39:14.473 EarCrush[11143:132894] [TwitterKit] did encounter error
with message "Unable to authenticate using the system account.": Error
Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server."
UserInfo={NSUnderlyingError=0x7fe043a49830 {Error
Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)"
UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}},
NSErrorFailingURLStringKey=https://api.twitter.com/oauth/request_token,
NSErrorFailingURLKey=https://api.twitter.com/oauth/request_token,
_kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.}
2016-08-04 15:39:14.473 MyProject[11143:132894] error: Error
Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server."
UserInfo={NSUnderlyingError=0x7fe043a49830 {Error
Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)"
UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}},
NSErrorFailingURLStringKey=https://api.twitter.com/oauth/request_token,
NSErrorFailingURLKey=https://api.twitter.com/oauth/request_token,
_kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.}
I mean sometimes because:
2 days ago I can login to Twitter normally
Yesterday I can not login,
This morning I can login but now (afternoon) I can not login even I don't change any code
I have update my Twitter via Fabric to latest version now (2.3) and I'm sure I have internet connection
I know my problem is very strangely but hope someone have a same problem like me can give me some suggestion for fix it

I had problem with login with Twitter and Firebase. This code working for me:
Twitter.sharedInstance().startWithConsumerKey("key", consumerSecret: "secret")
in AppDelegate. Then, when you tap on your custom login button call this:
Twitter.sharedInstance().logInWithCompletion() { session, error in
if let session = session { ... })
If you using Fabric, you don't need to call Fabric.with([Twitter.self]).

Related

ios login with google not working getting error always request timeout

I am getting error from last 2 days
Task <4098D1A9-4E3A-4A42-A381-3660F15CCD98>.<1> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=60, NSUnderlyingError=0x2813fb780 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), viable, interface: en0, ipv4, dns, _kCFStreamErrorCodeKey=60, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <4098D1A9-4E3A-4A42-A381-3660F15CCD98>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
),
NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=https://oauth2.googleapis.com/token, NSErrorFailingURLKey=https://oauth2.googleapis.com/token, _kCFStreamErrorDomainKey=1}
Previously its working fine what was the cause?

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!

Fail to connect with Firebase [IOS/Swift]

I encountered a weird problem trying to connect with firebase in my project. I already followed all necessary steps - firebase config, cocopod, google.plist - but I keep getting these error messages in this screenshot. Does anyone else encounter this problem and how did you resolve it?
Sceenshot
AppDelegate
import UIKit
import Firebase
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
}
Console
2020-10-25 10:47:24.604330-0400 test2[2991:35955] Connection 1: received failure notification
2020-10-25 10:47:24.604477-0400 test2[2991:35955] Connection 1: failed to connect 1:61, reason -1
2020-10-25 10:47:24.604584-0400 test2[2991:35955] Connection 1: encountered error(1:61)
2020-10-25 10:47:24.609628-0400 test2[2991:35955] Task <EF95DB6A-2445-4E58-9B2F-AFA35EE0A68E>.<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:61])
2020-10-25 10:47:24.616313-0400 test2[2991:35955] Task <EF95DB6A-2445-4E58-9B2F-AFA35EE0A68E>.<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSUnderlyingError=0x600001748c90 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://firebaselogging-pa.googleapis.com/v1/firelog/legacy/batchlog, NSErrorFailingURLKey=https://firebaselogging-pa.googleapis.com/v1/firelog/legacy/batchlog, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.}
2020-10-25 10:47:24.645716-0400 test2[2991:35949] 6.34.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60900000 started
2020-10-25 10:47:24.649697-0400 test2[2991:35949] 6.34.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/)
2020-10-25 10:47:24.651125-0400 test2[2991:35955] 6.34.0 - [Firebase/Analytics][I-ACS023171] Resetting App Measurement data
2020-10-25 10:47:24.752809-0400 test2[2991:35975] 6.34.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-10-25 10:47:24.788481-0400 test2[2991:35949] 6.34.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
2020-10-25 10:47:24.789629-0400 test2[2991:35949] 6.34.0 - [Firebase/Analytics][I-ACS023220] Analytics screen reporting is enabled. Call +[FIRAnalytics logEventWithName:FIREventScreenView parameters:] to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist
2020-10-25 10:47:39.183384-0400 test2[2991:36053] [] nw_socket_handle_socket_event [C3.1:3] Socket SO_ERROR [61: Connection refused]
2020-10-25 10:47:39.183765-0400 test2[2991:36053] [BoringSSL] nw_protocol_boringssl_handshake_negotiate_proceed(726) [0x7fd4bee004a0] handshake failed at state 0
2020-10-25 10:47:39.185931-0400 test2[2991:36053] Connection 3: received failure notification
2020-10-25 10:47:39.186090-0400 test2[2991:36053] Connection 3: failed to connect 1:61, reason -1
2020-10-25 10:47:39.186224-0400 test2[2991:36053] Connection 3: encountered error(1:61)
2020-10-25 10:47:39.190919-0400 test2[2991:36053] Task <69F833DC-E03D-46E7-A72D-DE7246C8BDFF>.<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:61])
2020-10-25 10:47:39.192171-0400 test2[2991:35790] Task <69F833DC-E03D-46E7-A72D-DE7246C8BDFF>.<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x600001732970 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <69F833DC-E03D-46E7-A72D-DE7246C8BDFF>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=("LocalDownloadTask <69F833DC-E03D-46E7-A72D-DE7246C8BDFF>.<1>"), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://app-measurement.com/config/app/1:955410733527:ios:c82bc7afb517ae10479392?platform=ios&app_instance_id=3A4D3A72AC624838AB769B6871063F58&gmp_version=60900, NSErrorFailingURLKey=https://app-measurement.com/config/app/1:955410733527:ios:c82bc7afb517ae10479392?platform=ios&app_instance_id=3A4D3A72AC624838AB769B6871063F58&gmp_version=60900, _kCFStreamErrorDomainKey=1}
2020-10-25 10:47:39.194966-0400 test2[2991:36054] 6.34.0 - [Firebase/Analytics][I-ACS901017] Encounter network error. Code, error: -1004, Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x600001732970 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <69F833DC-E03D-46E7-A72D-DE7246C8BDFF>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=("LocalDownloadTask <69F833DC-E03D-46E7-A72D-DE7246C8BDFF>.<1>"), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://app-measurement.com/config/app/1:955410733527:ios:c82bc7afb517ae10479392?platform=ios&app_instance_id=3A4D3A72AC624838AB769B6871063F58&gmp_version=60900, NSErrorFailingURLKey=https://app-measurement.com/config/app/1:955410733527:ios:c82bc7afb517ae10479392?platform=ios&app_instance_id=3A4D3A72AC624838AB769B6871063F58&gmp_version=60900, _kCFStreamErrorDomainKey=1}
2020-10-25 10:47:39.197349-0400 test2[2991:36054] 6.34.0 - [Firebase/Analytics][I-ACS023128] Network request failed to fetch remote config. Code, Error: 0, Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x600001732970 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <69F833DC-E03D-46E7-A72D-DE7246C8BDFF>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=("LocalDownloadTask <69F833DC-E03D-46E7-A72D-DE7246C8BDFF>.<1>"), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://app-measurement.com/config/app/1:955410733527:ios:c82bc7afb517ae10479392?platform=ios&app_instance_id=3A4D3A72AC624838AB769B6871063F58&gmp_version=60900, NSErrorFailingURLKey=https://app-measurement.com/config/app/1:955410733527:ios:c82bc7afb517ae10479392?platform=ios&app_instance_id=3A4D3A72AC624838AB769B6871063F58&gmp_version=60900, _kCFStreamErrorDomainKey=1}
2020-10-25 10:47:39.198538-0400 test2[2991:36054] 6.34.0 - [Firebase/Analytics][I-ACS023129] Network fetch failed. Will retry later. Code, error: 0, Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x600001732970 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <69F833DC-E03D-46E7-A72D-DE7246C8BDFF>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=("LocalDownloadTask <69F833DC-E03D-46E7-A72D-DE7246C8BDFF>.<1>"), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://app-measurement.com/config/app/1:955410733527:ios:c82bc7afb517ae10479392?platform=ios&app_instance_id=3A4D3A72AC624838AB769B6871063F58&gmp_version=60900, NSErrorFailingURLKey=https://app-measurement.com/config/app/1:955410733527:ios:c82bc7afb517ae10479392?platform=ios&app_instance_id=3A4D3A72AC624838AB769B6871063F58&gmp_version=60900, _kCFStreamErrorDomainKey=1}
1- I think everything is going well but it's appearing in the error that you may have a poor connection " Could not connect to the server "
My advice is to try it again and make sure from google Plist that it's documented under the same bundle identifier
2- If the previous doesn't work, just try to update the pod
3- In the worst case try to uninstall it & install it again

Flakey connection to dev machine

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.}

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