iosswiftaws-sdkaws-sdk-iosamazon-kinesis-firehose

AWSFirehoseRecorder saveRecord seems never saving any record


In app didFinishLaunchingWithOptions

    let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "my-identity-pool-id")
    let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider)
    AWSFirehoseRecorder.register(with: configuration!, forKey: "somestupidkey")

In view controller

let firehoseRecorder = AWSFirehoseRecorder(forKey: "somestupidkey")
let yourData = "Test_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_data".data(using: .utf8)
firehoseRecorder.saveRecord(yourData, streamName: kinesisDirectory)

NSLog("Added %d records", firehoseRecorder.diskBytesUsed) // ALWAYS ZERO!!!!

It looks like it's not writing data at all. diskBytesUsed always returns 0. Any idea what might be issue?
Thanks


Solution

  • Ok, solved it. It turned to be authentication issue. So using this code will actually catch the error message of why the records weren't submitted:

                firehoseRecorder?.saveRecord(jsonData, streamName: "YourStreamName").continueOnSuccessWith(block: { (task:AWSTask) -> AWSTask? in
                    NSLog("RecordBeen saved")
                    return nil;
                }).continueWith(block: { (task:AWSTask) -> Any? in
                    if let error = task.error as? NSError {
                        print("Error: \(error)")
                        return nil
                    }
                    return nil
                })
    

    Showing error messages actually helped.

    Hope it helps someone else having same issue.

    Thanks.