-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The network connection was lost #3437
Comments
@PatilAkshays Thanks for submitting the issue. Can you provide additional details to help reproduce the issue? Which library and version are you using? Is there a specific API that is getting the network connection lost? Can you provide a sample app that reproduces the issue or additional app logs? |
Code Snippet private func configureAmplify() {
do {
if AppScheme.current.allowsDebugLogging {
SDKLoggingSystem.initialize(logLevel: .debug)
Amplify.Logging.logLevel = .debug
}
try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.add(plugin: AWSAPIPlugin(sessionFactory: self))
try DataStoreManager.configure(onError: { [weak self] error in
Snacker.debugSnack(.error(error.amplifyDescriptionOrDefault))
self?.eventTracker.track(
event: .error(
name: "DataStoreError",
error: error,
message: "❌ DataStore Synchronization error: \(error.amplifyDescriptionOrDefault)"
),
extras: [
"error": error.amplifyDescriptionOrDefault
]
)
})
try Amplify.add(plugin: AWSS3StoragePlugin())
configureDataStoreEventListener()
try Amplify.configure()
eventTracker.track(event: .logOnly(message: "AWS Amplify configured"))
} catch {
Snacker.debugSnack(.error(error.amplifyDescriptionOrDefault))
eventTracker.track(
event: .error(
name: "AmplifyConfigurationError",
error: error,
message: "Failed to configure AWS Amplify: \(error.amplifyDescriptionOrDefault)"
),
extras: [
"error": error.amplifyDescriptionOrDefault
]
)
}
}
public static func configure(onError: @escaping (Error) -> Void = { _ in }) throws {
let syncExpressions = [
DataStoreSyncExpression.syncExpression(XYZTableModel.schema, where: {
if let dateLimit = dateLimit {
XYZTableModel.keys.user_id.eq(userId).and(XYZTableModel.keys.data_timestamp.gt(dateLimit.temporalDateTime))
} else {
XYZTableModel.keys.user_id.eq(userId)
}
}),
]
try Amplify.add(plugin: AWSDataStorePlugin(
modelRegistration: DataStoreModels(),
configuration: .custom(errorHandler: onError, syncMaxRecords: UInt.max, syncExpressions: syncExpressions)
))
} To ReproduceSteps to reproduce the behavior:Synching data with Cloud while application is in background mode using REST api in for loop. Observed BehaviorData is not synced with cloud, throwing "network connection was lost." error while we have strong internet connection. Expected BehaviorIt should upload the data on clould. Environment(please complete the following information):SDK Version: Dependency Manager: Package Dependancies Swift Version : 5 Xcode Version: 15.0.1 (15A507) Device Information (please complete the following information): Device: iPhone Logs:
|
Thanks for the details @PatilAkshays
Can you clarify "REST api in for loop."? From the code snippet i looks like you are using DataStore If the app was moved to the background, there are certain restrictions that the OS will impose on the network activity of the app. The failures are expected and when the app goes back to the foreground and DataStore is active, then the failed mutation events should be retried. |
Related feature request #3434 about uploading data in the background |
I misunderstood the logic, I have verified the concept and added new scenario.Steps to reproduce the behavior:Synching data with Cloud. Observed BehaviorData is not synced with cloud, throwing
error while we have strong internet connection.
Expected BehaviorData Sync should be happened. Application BehaviorSyncing start Can you please clarify on these below points
|
Hi @PatilAkshays, any DataStore operation performed such as
You can see the Amplify.Hub.publisher(for: .dataStore).sink { event in
print("[DataStore] \(event)")
}.store(in: &sinks) Moving out the implicit start from the save will make it easier to pinpoint where the error is coming from, ie. is the network connection error coming from the subscriptions or the mutation request for syncing to cloud, or somewhere else after DataStore.start is called? Calling DataStore.start() on an already started DataStore will do nothing and return. You can stop and start it to restart the sync process, but usually this is done in other use cases like changing the syncExpression and restarting to sync to use the new filter |
@lawmicha we're still seeing this issue as well for multiple users. We'll post whatever logs we have. Considering that we're relying on data in DynamoDB for our algorithms, this is a must-fix. Has any progress been made or you're looking for more information? |
@madej10 Thank you for your message. Could you please open a new issue with your environment information, verbose logs and reproduction steps? This will help in tracking it better. |
**
** Amplify Version: -- 12.12.2 Sample Code: {
} |
@madej10 Are you able to get more information on this issue? |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
I am using amplify AWS to sync Application with cloud, some times I am getting error as "The network connection was lost" I have strong internet connection but it is throwing this error.
To Reproduce
Steps to reproduce the behavior:
The text was updated successfully, but these errors were encountered: