Make an HTTP request using
SessionManager.request(_ url: URLConvertible, method: HTTPMethod = default, parameters: Parameters? = default, encoding: ParameterEncoding = default, headers: HTTPHeaders? = default) -> DataRequest
The request to work, and not spit up errors
Every request I hit prints this out:
2018-03-13 11:17:00.732122-0600 MYAPP[1452:694869] CredStore - performQuery - Error copying matching creds. Error=-25300, query={
class = inet;
"m_Limit" = "m_LimitAll";
"r_Attributes" = 1;
sync = syna;
}
According to this answer: https://stackoverflow.com/a/46806008/3877767 it seems to be related to Credential Storage, but I don't use that for anything so it seems to be something Alamofire is doing
I found this bit of code in Request.swift that seems to be responsible for the error, but I'm not sure how to silence/handle this error
if let credentialStorage = self.session.configuration.urlCredentialStorage {
let protectionSpace = URLProtectionSpace(
host: host,
port: url.port ?? 0,
protocol: url.scheme,
realm: host,
authenticationMethod: NSURLAuthenticationMethodHTTPBasic
)
if let credentials = credentialStorage.credentials(for: protectionSpace)?.values {
for credential in credentials {
guard let user = credential.user, let password = credential.password else { continue }
components.append("-u \(user):\(password)")
}
} else {
if let credential = delegate.credential, let user = credential.user, let password = credential.password {
components.append("-u \(user):\(password)")
}
}
Alamofire version: Alamofire 4.7.0
Xcode version: Version 9.2 (9C40b)
Swift version: 4.0
Platform(s) running Alamofire: iOS 11.0+
macOS version running Xcode: 10.13.4 Beta (17E182a)
the same bug
@4taras4 @bryan1anderson if you execute the same request in POSTMAN, do you by chance receive an html reponse, instead of json?
@bryan1anderson Given this is something new happening only occasionally on iOS 11, and users on the Stack Overflow post are seeing it when using AVPlayer, I'm inclined to believe it's an underlying system bug. Alamofire doesn't do anything with the credential storage unless you have one set. Is this resulting in failing requests or just being printed in the console?
I have the same error when streaming videos from a URL using AVPlayer. I do use Alamofire in my app, but I use it in a completely different class so in my case I don't think it has anything to do with Alamofire. Also, I created a blank new test project with no Alamofire and I get the same error.
I have the same issue, but I am using Alamofire and not AVPlayer.
So I was only able to fix this by switching to SwiftHTTP.
In my research I've found many others seeing this same error (like CouchBase), and they all point to it being a spurious bit of debug info printed to the console when the credential store fails to find an item for a protection space. This is expected if you're querying the store but nothing's been stored in it yet, which is why even Apple's framework code sees it. I'm guessing this is yet more debug output that's now visible due to some Apple change. Nothing for us to do here.
i have a same issue but not using "URLSession.shared.dataTask "
So its just a console output and not an error ? My Alamofire request should work fine ?
I found one solution on stackoverflow. Hope this might help https://stackoverflow.com/questions/50342214/how-to-upload-an-image-using-alamofire-with-basic-authentication
i decided problem:
let credentialData = "(user):(password)".data(using: String.Encoding.utf8)!
let base64Credentials = credentialData.base64EncodedString(options: [])
let headers = ["Authorization": "Basic (base64Credentials)"]
Alamofire.request(url, method: .get, parameters: params,encoding: URLEncoding.default,headers: headers)
.responseJSON{
response in
guard let value = response.result.value else {return}
print(value)
}
I found the same issue.
May I send SMS to the phone on the app directly?
My code :
let accountSID = "XXXXXXxxxxXXXXXXXX"
let authToken = "XXXXXXxxxxXXXXXXXX"
let servicePhone = "+123456789"
let riderPhone = "+1234567890"
var Body = "Your trip has finished:\n"
Body += "From XXX to XXXXX\n"
Body += "Fare: 1500 usd"
Body += "Thanks for using our App."
let url = "https://api.twilio.com/2010-04-01/Accounts/\(accountSID)/Messages"
let parameters = ["From": servicePhone, "To": riderPhone, "Body": Body]
Alamofire.request(url, method: .post, parameters: parameters)
.authenticate(user: accountSID, password: authToken)
.responseJSON { response in
switch response.result {
case .failure:
print("fail")
case .success(let data):
print(data)
}
}
RunLoop.main.run()
issue:
2020-01-29 10:56:28.166211+0800 driver[948:216003] CredStore - performQuery - Error copying matching creds. Error=-25300, query={
class = inet;
"m_Limit" = "m_LimitAll";
ptcl = htps;
"r_Attributes" = 1;
sdmn = "Twilio API";
srvr = "api.twilio.com";
sync = syna;
}
fail
2020-01-29 10:56:41.469607+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.470644+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.493414+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.494251+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.512466+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.513086+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.528623+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.529129+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.570182+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.570853+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.581670+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.582050+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.592689+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:41.593080+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:58.088635+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:58.089526+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:58.112919+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 10:56:58.113652+0800 driver[948:215600] [Storyboard] Unknown class _TtC12MarqueeLabel12MarqueeLabel in Interface Builder file.
2020-01-29 11:00:50.567954+0800 driver[948:216915] Request
success = 1;
}
2020-01-29 11:05:50.399153+0800 driver[948:217869] Request
success = 1;
}
2020-01-29 11:10:50.433298+0800 driver[948:218768] Request
success = 1;
}
In Alamofire Request.swift there a function, cURLRepresentation().
In the function it access URLCredentialStorage:
if let credentials = credentialStorage.credentials(for: protectionSpace)?.values {
for credential in credentials {
guard let user = credential.user, let password = credential.password else { continue }
components.append("-u \(user):\(password)")
}
}
and cURLRepresentation() is called when access debugDescription variable:
open var debugDescription: String {
return cURLRepresentation()
}
So.. in my case.. debug code, print(), triggered the error log.
Alamofire.upload(
multipartFormData: { MultipartFormData in
}, to: "https://xxx.yyy.com/aaa.php") { (result) in
print("result: \(result)")
}
Is it expected behavior to access URLCredentialStorage whenever printing debug description even though I don't use URLCredentialStorage?
It made me confused and I had to find out what was wrong.
For reference. I get this error in Alamofire 5(iPadOS 13.6) when call backend IIS ASP.Net set windowsAuthentication enable="true".
Most helpful comment
In my research I've found many others seeing this same error (like CouchBase), and they all point to it being a spurious bit of debug info printed to the console when the credential store fails to find an item for a protection space. This is expected if you're querying the store but nothing's been stored in it yet, which is why even Apple's framework code sees it. I'm guessing this is yet more debug output that's now visible due to some Apple change. Nothing for us to do here.