I have a React application that I am building. I have a custom Sign Up page and Sign In page. Both were working about 20 minutes ago and now they are not. I am getting a very generic "NetworkError" returned from Auth.signIn and Auth.signUp. Nothing has changed in the code or configuration since it was working. I am getting the error when I run the application locally and when I run it in my S3 bucket. Anybody have any ideas?
@goalguy10 on which region do you have your Cognito User Pool? I can try to replicate the issue. Can you try on a different network. Maybe a firewall is blocking the requests to Cognito?
Which version of amplify are you using?
I believe it is east-1 Virginia. I tried on multiple networks and even tried it hosted with amplify. It was working at one point then 15-20 minutes later it was no longer working. I am using the most recent version.
I created userpools on virginia and oregon and both work correctly with aws-amplify. @goalguy10 Are you located on the east coast?
@goalguy10 what HTTP response code are you getting? If you enable 'DEBUG' Amplify.Logger.LOG_LEVEL = 'DEBUG'
maybe there is something else.
I do have the same problem. The weird thing is my friends tried to signup also and the got the same error but they still got the verification code !
@elorzafe yes I am located on the east coast. I do not get any http response. I get the error “networkerror” returned and then the page refreshes. I will turn on debugger and post the results.
Same result with debugger. No other information other then network error. My user pool is in Virginia. I even deleted and re added the amplify Auth with no change.
@goalguy10 I will continue trying to diagnose this issue
@goalguy10 Can you paste the HTTP response code?
I was able to reproduce the issue using a completely new project. I am not getting any HTTP response. the only thing I get is the following console prinout:
error signing in...:
{…}
​
code: "NetworkError"
​
message: "Network error"
​
name: "Error"
​
<prototype>: Object { … }
main.chunk.js:159:9
That is the response to:
Auth.signIn(username, password)
.then(user => {
console.log('Success');
})
.catch(err => {
console.log('error signing in...: ', err);
})
With this same project I can register and login using the withAuthenticator.
@goalguy10 can you paste (commenting the sensible parts) on how you are configuring amplify, and importing Auth.
I am following the instructions here: https://aws-amplify.github.io/docs/js/start?platform=react
and here: https://aws-amplify.github.io/docs/js/authentication
My project is setup exactly how the instructions state.
@goalguy10 I have just tried this react-app and it works ok for me. Can you try this code (replacing username and password)
import React, { Component } from 'react';
import './App.css';
import Amplify, { API, Auth } from 'aws-amplify';
import config from './aws-exports';
Amplify.configure(config);
class App extends Component {
async getUserInfo() {
const user = await Auth.currentUserInfo();
console.log({ user });
}
signIn(){
Auth.signIn("xxxxxxxxx", "xxxxxxxx");
}
signOut(){
Auth.signOut();
}
render() {
return (
<div className="App">
<button onClick={this.getUserInfo}>userInfo</button>
<button onClick={this.signIn}>signIn</button>
<button onClick={this.signOut}>signOut</button>
</div>
);
}
}
export default App;
This is my aws-exports.js
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.
const awsmobile = {
"aws_project_region": "us-east-1",
"aws_cognito_identity_pool_id": "us-east-1:********-****-****-****-*************",
"aws_cognito_region": "us-east-1",
"aws_user_pools_id": "us-east-1_*********",
"aws_user_pools_web_client_id": "*************************"
};
export default awsmobile;
I changed the sign it to:
signIn(){
Auth.signIn("xxxx", "xxxxxx").then(user => console.log("User: ", user)).catch(err => console.log("Error: ", err));
}
and I am able to login. I then added a username and password input field and signIn() worked.
Now, when I try to incorporate this into my application it is failing with network error.
@goalguy10 can you share some screenshots from your network tab. Maybe I can diagnose better with that information.
@goalguy10 I'm with the same problem but my code is for React Native. I tryed to simulate the problem with another two smartphones (iPhone X - iOS 12 and Moto G5 - Android 8.1) and worked! I'm using Moto G6 Plus with Android 9.0... It's possible to be an OS problem?
@guiaamaral Did you solve this problem for your Moto G6 Plus with Android 9.0?
I'm facing the same issue with my Android devices only, for me it's a React Native app too.
@jtarini Nothing yet! I don't now why this happen. I tried to debbug but with no success.
I'm having the same error but from changePassword. signIn and deleteUser both work for me. Has anyone made progress?
With the debugger I get this:
[DEBUG] AuthClass - Getting the session from this user: CognitoUser {username: "xxxx", pool: CognitoUserPool, Session: null, client: Client, signInUserSession: CognitoUserSession, …}
[DEBUG] AuthClass - Succeed to get the user session CognitoUserSession {idToken: CognitoIdToken, refreshToken: CognitoRefreshToken, accessToken: CognitoAccessToken, clockDrift: 1}
[DEBUG] AuthClass - change password failure {code: "NetworkError", name: "Error", message: "Network error"}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.
I am seeing this too. In my case, I have multiple Cognito triggers associated with Lambda functions for custom authentication. The problem always seems to occur during cold starts of my Lambdas. If my dev environment has been sitting all night and I attempt a login in the morning, I will see this error for up to 30 minutes.
I only get this error when calling Auth.sendCustomChallengeAnswer
. My calls to Auth.signIn
and Auth.signUp
work fine.
Auth.sendCustomChallengeAnswer
will usually invoke my Cognito trigger assigned to Verify Auth Challenge Response. When I start seeing this NetworkError
problem, the Lambda associated with this trigger is not called. There is a disconnect somewhere between Cognito and that function during these events. It seems like when Lambda is cold starting a function, Cognito is unable to deal with it.
Here is the error I'm catching
{"code":"NetworkError","name":"Error","message":"Network error"}
This issue should be re-opened.
Amplify 1.0.31
I also encounter this same issue with react-native, while the same setup works in a simple react project!
joebernard @boboci9 I've also had issues with this on react native when calling the Auth.sendCustomChallengeAnswer
method. Has anyone had an update on this?
I am also seeing this issue using Vue.js
both the username and password are populated.
try {
await Auth.signUp({
username, password
})
} catch(e) {
console.log('Exception: ', e)
}
I enter the page for the first time, enter the datq and try to signup - I get an error message: {code: "NetworkError", name: "Error", message: "Network error"}. The page represents, I enter the details againa and it works.
Had the same issue with React. The set up works with the AWS web UI, but doesn't work with amplify Auth.
Turns out I didn't add event.preventDefault()
before calling Auth.signIn()
, with that, it got resolved.
Same Error, we are working fine a few hours ago, and suddenly:
{"code": "NetworkError", "message": "Network error", "name": "Error"}
Same error here, we are experiencing a spike in Network errors since late afternoon (after 6PM London time) on 22 Oct 2019. Any idea?
I was having this same problem in my react app - while it is slightly mentioned in an answer previously, it seems to be looked over, so ill outline the EASY EASY fix i was able to do.
I realized that in my react app it was refreshing the page by default when i would submit a form, before the await Amplify.signUp
was able to finish. that's why sometimes it would work rarely, but mostly not.
All i did was add an event.preventDefault()
on the form's onSubmit
handler, and voila!
pretty simple, but it was not made clear thats all i needed with the answers above, i found this info elsewhere, so i thought i'd save other people with the same issue the trouble of searching elsewhere!
We're having the same issue intermittently with a react-native app. I checked the lambda metrics and it doesn't seem that we're anywhere close to our timeout limit there. This happens across Android and iOS devices. The error is the following:
{
code: NetworkError,
message: Network error,
name: Error
}
We're having the same issue with a react-native app. any solution for this?
did anyone get a solution?
Any Solutions?
Everything was working fine for me in vue js and then I had to install react native stuff for work and also updated my aws stuff and went back to create a vue project and got the Network Error issue for GraphQL. So Idk if it was something with that react native stuff I installed cause I see other people mention react-native or an aws amplify update or what
Am also having some users reports this. Angular app.
For anyone running into this, I'm able to repro my issue if my system's clock is off. See https://github.com/aws-amplify/amplify-js/pull/5869. The actual call to Cognito was working, I had a followon call to API Gateway that was failing. So I believe users had some clock drift. Fortunately the amplify team just merged in a fix for this 2 days ago.
@elorzafe Was a solution ever found for this issue? I keep getting Network Error
when trying to Auth.SignUp().
signUp = async (event) => {
event.preventDefault();
const username = "John"
const password = "Abcdefgh12"
const email = "[email protected]"
await Auth.signUp({
username,
password,
attributes: { email }
})
.then(() => {
console.log('sign up successful!')
Alert.alert('Enter the confirmation code you received.')
})
.catch(err => {
if(err['code'] === "UsernameExistsException"){
Alert.alert('Username already taken', 'Please try another')
}
if (! err.message) {
console.log('Error when signing up: ', err)
Alert.alert('Error when signing up: ', err)
} else {
console.log('Error when signing up: ', err.message)
Alert.alert('Error when signing up: ', err.message)
}
})
}
hey everyone who got this issue here's whats happened in my scenario. the cause for this issue was that the emulator doesn't have the access to the internet , please make sure that you emulator has the network connection, that's the reason to display error "Network Error". Please make sure your emulator is displaying wifi icon.
@nir099 Yup, Emulator can access the internet. I get a 'This connection is not private' page on the web browser, but when i click visit anyway, it does get me to the website. Perhaps this is the issue?
@nir099 Yup, Emulator can access the internet. I get a 'This connection is not private' page on the web browser, but when i click visit anyway, it does get me to the website. Perhaps this is the issue?
hey @chai86 did you try this, shut down the laptop, start again then connect to the internet then run the emulator, verify the wifi icon is on, remove the app from the emulator , run npx react-native run-android if you using RN. then try again. the reason why I'm telling this because in my problem it got solved automatically, i didn't do anything in particular in next day when i run the emulator it was working. here's another idea make another emulator instance run the app in there.
@nir099 Unfortunately that didn't work. @ashika01 any ideas?
I was having this issue when using React Redux because the event was firing the defaults. Fixing the issue for me was as simple as adding event.preventDefault();
to the form submit function.
@benjeater I also faced this issue, e.preventDefault() worked for me as well!
👍 event.preventDefault()
did the trick.
Most helpful comment
Had the same issue with React. The set up works with the AWS web UI, but doesn't work with amplify Auth.
Turns out I didn't add
event.preventDefault()
before callingAuth.signIn()
, with that, it got resolved.