SSL_ERROR_SSL(1): operation failed within the library
Deadlock
I assume spotifyRequest will be called on the main thread.
So if the main thread reaches the line
group.wait()
and this line of responseJSON completionHandler was not called yet:
group.leave()
then the main thread is blocked due to the call of group.wait() above.
Due to the blocked main thread group.leave() can't be called. Classical deadlock.
Verfication
Setting a breakpoint to the line
if let safeStatus = status {
shows that this line is never called.
Minimal Example that is running
As a starting point here the code for a minimal example that delivers a result.
import UIKit
import Alamofire
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.contactSpotify {
print ("result: \(String(describing: $0)) error: \(String(describing: $1))")
}
}
func contactSpotify(completion: @escaping ([String: Any]?, Error?) -> Void) {
let url = URL(string: "https://accounts.spotify.com/api/token")!
Alamofire.request(url,
method: .post,
parameters: ["grant_type": "refresh_token",
"client_id": "<someClientId>",
"refresh_token": "<someRefreshToken>",
"client_secret": "<someClientSecret>"])
.validate()
.responseJSON { response in
guard response.result.isSuccess else {
completion(nil, response.result.error)
return
}
completion(response.result.value as? [String: Any], nil)
}
}
}
This gives as output in the console:
result: Optional(["access_token": XXX, "scope": user-read-email user-read-private, "token_type": Bearer, "expires_in": 3600]) error: nil
see Screenshot:
ATS Settings in info.plist
Spotify offers a valid TLS certificate chain on their server. So there is no need for ATS settings in info.plist.
SSL Warnings in Console
I get the same SSL warnings in the console when I run the application on an iOS 12 simulator like you. Nonetheless the connection is established and the request delivers data. Perhaps this is gone in one of the next betas.
React Native crashes on react-native run-ios
1: If you have pod
installed, Make sure you check all your libraries.You likely have some issue with an installed external library.
and make sure you run pod install
and delete node_modules
folder and then run npm install
again (close the packager too)
2: You can also use sentry
or any other crash reporting library to detect crashes, It will give you the exact line number.(Make sure you install the react-native version).
3: Sometimes the crash reporting libraries won't work, the reason can be that the crash occurs before the js bundle
is loaded and because of that, the library is not yet initialised and it can't detect the crash. If so you can install a native crash reporting library, You can use fabric
for that, or even bugsnag
.
4: Even if these 3 steps don't work, Sometimes due to some problem in certificates the app can crash on startup, and sometimes the app can work for few days and then crash suddenly, If this behaviour occurs. Make sure your certificates are generated correctly.
These are the few scenarios where this kind of crash occurs. Usually its the first one
Related Topics
Dependency Injection in View Controller
Struct Memberwise Initialization - Omitting Values for Properties That Have Defaults
How to Use Swipe to Dismiss While Presenting a Fullscreen Modal in iOS 13
Control a Nstabviewcontroller from Parent View
Cannot Convert [Int] to [Int] in Generic Implementation
Horizontal Scrolling in Spritekit (Vs. a Viewcontroller)
Picker Not Working When Editmode Is Active
Make a Publisher from a Callback
How to Use Passed Parameters in Swift Setmethodcallhandler - Self.Methodname(Result: Result)
Window Title Bar Appears Transparent Issue (Not Really Transparent)
Editing a Package Dependency as a Local Package
Using Dateformatter with Timezone to Format Dates in Swift
Animation Delay on Left Side of Screen in iOS Keyboard Extension
Advantage of Key-Value Coding in Swift 4
How to Restore In-App Purchases Correctly