React-native, Firebase network error while trying to log in - javascript

I've followed a React-native login tutorial using Firebase, I use create-react-native-app for easy dev(my package.json), I'm using NodeJS v6.10.1, I'm using Note 4 Device(4.4.4), I enabled Email/Password authentication within Firebase console, for some reason I get:
{
code: "auth/network-request-failed",
message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred."
}
I didn't forgot to use firebase.initializeApp and my code is:
firebase.auth().signInWithEmailAndPassword(email, password)
.catch(e0 => {
console.log(e0);
firebase.auth().createUserWithEmailAndPassword(email, password)
.catch(e1 => {
console.log(e1);
this.setState({ error: 'Authentication Failed.' });
});
});
For both I get the same error object.

So the problem was:
It all starts by this Debugger and device times have drifted by more than 60s, due to other, adb related problem I couldn't run adb shell "date -sdate +%m%d%H%M%Y.%S", after I fixed my adb problem I run adb shell "date -sdate +%m%d%H%M%Y.%S", now the Firebase error was saying: such as timeout, adb(my computer) time was -4min than the device, so to fix that I changed the time on my computer, adding 4min so it will match the device time.
What I assume was the problem, I'm not a networks expert so please if anyone can fix some of my assumptions if there is something wrong:
For explanation I just use unreal stuff(reqTimestamp,...), but the concept is valid(I hope):
The device signed the request with a timestamp and a timeout, for example, reqTimestamp=22:16, reqTimeout=22:17, my device is connected throught my wifi, so when the modem connected to my computer, a basic check on my computer or internally the modem, such as: if(reqTimeout > timeNow) reject, could prevent the request from even leave my network so Firebase issue this generic error regarding network problem.

I was getting this same error for a react-native project running using expo on an android device emulator(on windows).
I know this will sound weird but in my case I was getting this error when using internet from my phone's hotspot. When I switched to my normal wi-fi internet connection, the error went away.
Hope this helps.

I have the same error.
In my case it caused by more then one identifier for the same email in Firebase -> Authentication.
Do not know why I have more than one record for the same email, but after deleting all and login again. The problem is resolved.

I had the same issue. I connected to a VPN, the error went away.

Related

WebSocket connection to 'wss://api.chatengine.io/person_v4/?session_token=st-7b6efb7e-b283-4337-a5f2-a1ab9b471ee0' failed:

i'm working on a chat application using Reactjs and Chat Engine my app is not workin due to this error message :
"WebSocket connection to 'wss://api.chatengine.io/person_v4/?session_token=st-7b6efb7e-b283-4337-a5f2-a1ab9b471ee0' failed: ".
Thank you very much.
After trying to connect directly to wss://api.chatengine.io/person_v4/?session_token=st-7b6efb7e-b283-4337-a5f2-a1ab9b471ee0 using https://www.piesocket.com/websocket-tester it failed once with the exact error you provided, then connected successfully three times on two consecutive attempts.
Do try again.
I wanted to suggest contacting support with chatengine.io being a private service, however from the last page of the Terms & Conditions, the e-mail address listed there points to a suspended Squarespace account so might not work.
So the next suggestion is to find a better (actively maintained) service.

Unable to retrieve user's mysite URL OneDrive explorer javascript problem

I have some strange problem with onedrive explorer:
https://github.com/OneDrive/onedrive-explorer-js
I have configured my app credentials, have added the permissions:
Files.Read
Files.Read.All
offline_access
profile
Sites.Read.All
User.Read
and get this error:
https://graph.microsoft.com/v1.0/me/drive/root?expand=thumbnails,children(expand=thumbnails(select=large))
502
Bad Gateway
additional error text:
Unable to retrieve user's mysite URL.
I have tried with 3 different accounts.
Additionally, on graph explorer I have an error :
Must be authenticated to use '/drive' syntax (It gives my profile details and nothing else) from -
https://developer.microsoft.com/en-us/graph/graph-explorer
Can somebody let me know what could be the problem?
Thank you !
Problem is in the azure subscription, not in any of the accounts. I have created new subscription and all is fine. Seems that this use case or test cannot be done for free.
Thanks for the collaboration :)

Frequent "A network error (such as timeout, interrupted connection or unreachable host) has occurred." with Firebase

I'm using Firebase anon login to authenticate certain parts of our API.
This error "A network error (such as timeout, interrupted connection or unreachable host) has occurred." seems to pop up frequently with no apparent pattern.
This seems to happen in all types of browsers. Mobile, tablet or desktop but I can't for the life of me reproduce this error.
I've tried many different types of physical devices as well as Browserstack.
Some have suggested that users experiencing this aren't allowing Javascript or have some kind of browser extension preventing Firebase to work correctly. I find that hard to believe since this keeps happening very frequently. (Also I've never met a person in my whole career that has Javascript disabled).
I initialize Firebase like so in my React's index entry point.
if (!firebase.apps.length) {
// ... config setup
firebase.initializeApp(config);
}
firebase.auth().signInAnonymously()
.catch((error) => {
bugsnag.notify(error);
});
I'm using React 16.8.6 and Firebase 5.9.4.
Error seems to be originating in google-closure-library:
../node_modules/google-closure-library/closure/goog/async/nexttick.js:41:44
I'm hoping users aren't affected by this error but I have no idea if they are.
I fixed this issue(my issue) pausing my Kaspersky anti-virus. I found some other answers saying the html form tag caused this.

What is a TransientTransactionError in Mongoose (or MongoDB)?

I have server.js and db.js The db.js file interacts with my database using Mongoose and I use server.js to call functions from db.js :
var mongoose = require('mongoose');
mongoose.connect('', { useNewUrlParser: true })
var Schema = mongoose.Schema;
module.exports = function () {
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
return db.once('open', function() {
console.log("Connected to DB")
var postschema = new Schema({
title: String,
intro: String,
body: String,
author: String,
timestamp: { type: Date, default: Date.now }
});
var post = mongoose.model('post', postschema);
return {
newPost(title, intro, body, author) {
var newpost = new post({
title: title,
intro: intro,
body: body,
author: author
})
},
getPostsAll() {
post.find({}, function (err, res) {
return (`Error:${err} Posts:${res}`)
})
}
}
})
}
And my server.js calls three functions from db.js :
var DB = require('./db.js')
var db = DB()
db.getPostsAll()
db.newPost()
I don't understand why I get this error :
connection error: { MongoNetworkError: connection 4 to black-test-shard-00-01-ewyaf.mongodb.net:27017 closed
at TLSSocket.<anonymous> (E:\HTML\black-box\node_modules\mongodb-core\lib\connection\connection.js:276:9)
at Object.onceWrapper (events.js:272:13)
at TLSSocket.emit (events.js:185:15)
at _handle.close (net.js:541:12)
at TCP.done [as _onclose] (_tls_wrap.js:379:7)
name: 'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],
[Symbol(mongoErrorContextSymbol)]: {} }
What am I doing wrong? I found an article but can't make anything of it.
I had
'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],
[Symbol(mongoErrorContextSymbol)]:
I added my current IP to whiteList following "main page > security section > network access > add IP" in MongoDB website.
I hope this helps.
What is a TransientTransactionError
A TransientTransactionError is a transactional error that is classified as temporary, and if retried it may be successful. Furthermore, a TransientTransactionError write conflict occurs prior to a commit when no write lock has been taken and the transaction (new data) is not reflected in the transaction snapshot (previous data.) As a result, these errors are completely safe to retry until there is a successful commit.
Transactions that retry in this scenario are retried from the beginning of the transaction.
Keep in mind This error label is different than commit errors that happen when the lock has been taken but the transaction can't complete its commit. The error label for this is UnknownTransactionCommitResult. The reference to this is notable due to the difference in understanding where in your application an error is occurring and what may be the underlying cause and how the application can and or will respond due to different error types.
If you're using MongoDB supported drivers, there are two possible cause the code is getting this error:
Any database command error that includes the "TransientTransactionError" error label in the "errorLabels" field.
Any network error encountered running any command other than commitTransaction in a transaction.
The code example in MongoDB Transactions: retry-transaction show cased how to handle TransientTransactionError.
If the error message is MongoNetworkError, it means the transient transaction error is related to the network connectivity between the client and the server. This could either be a one time network glitch which is retry-able, or there is no network access which require network configuration. If the error is encountered on the first time the client trying to access the server, it is likely that there is network configuration needed. If the server is on MongoDB Atlas, please see Configure Whitelist Entries.
Go to your mongoDB Atlas Dashboard
Open Network Access (its there in side navbar)
Click on ADD IP ADDRESS
Click on allow from Any IP Address ( it basically give access to your dynamic IP address)
Now you are done.
If there is no security issue and you are just doing it for connecting:
While setting up the IP Whitelist; format should be 0.0.0.0/0 , you will not face the issue.
Moreover, as you have answered yourself, we can add the ip for which we need access.
I had the same issue/error, albeit on a Windows machine. Even though I thought I had started the mongodb service, I didn't see it running in Windows Services. So, I manually started the mongoDB service inside Services and then the error went away. Hope this helps!
I encountered this error when running the populatedb.js script in the MDN tutorial for Express/NodeJS.
The script was looking for a db connection starting with mongodb://, however my connection string from mongo started with mongodb+srv://.
I edited the script to check for this syntax instead, which resolved the error.
I hope this helps someone.
I had similar problem...
All day I was able to connect via mongoose. Then bang I started getting 'TransientTransactionError' error. I could connect to mongoDB via shell so I knew the server was up and running as expected.
IPv6/localhost. My IP switched from IPv4 to IPv6. I resolved the issue by disabling IPv6 and getting regular IPv4 IP.
EDIT -- seems I can reliably re/create this issue by connecting to 'localhost' while my NIC is configured with a IPv6 IP. Changing localhost->127.0.0.1 seems to resolve the issue.
Make sure the server didn't run out of storage space.
In my case, none of the suggested answers helped. I was pulling out my hair until I've noticed that the server ran out of storage space. Clearing up a few megabytes of storage solved the error immediately.
The TransientTransactionError actually makes sense in this scenario due to its nature of being a temporary error that could be resolved upon an explicit retry - though it did take me a while to figure out it had to do with a storage issue.
For me, the transient transaction error came whenever I switched from my wifi network to my phone's hotspot. If this happens to you too, go to MongoDB website where you have made your database and white list your current IP address again. This will solve your problem.
If you are using MongoDB Atlas. You need to Whitelist your IP address on the Atlas Console in the security settings.
If you still have this error, another reason is that you forgot to restart nodemon server after changing config file. CTRL+C and start again, that's how i solved it.
Security > Network Acess> Add IP Adress > Add Current Computer IP address.
Solved my problem.
Using mLab -- When your cluster is created, you need to add a database user (under the users tab) and make sure to not click the Make read-only checkbox. Once I did this, the errors went away. I was getting the same errors as above. The database user can be your login user name and password.
Go to your MongoDb Atlas dashboard. Click on Network Access, Click on add Ip Address and allow connectivity from any Ip Address.
This should solve your problem.
I had this problem when trying to connect my Heroku app to a MongoDB Atlas database.
If you do a on you terminal
heroku logs --tail
You might see
ERROR: { MongoNetworkError:
connection 4 to cluster0-shard-40-01-qnwp8.mongodb.net:27017 closed
name: 'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],
[Symbol(mongoErrorContextSymbol)]: {} }`
After whitelisting the server connection on MongoDB Atlas, the database connection error was resolved.
You can read about the error online but the solution for this problem is: go to you MongoDB atlas and add your IP address.
Go to:
main page > security section > network access > add IP
This problem is basically when the architecture do not know your own IP address.
Also, copy-paste directly to google to get straight forward solution.

Get avatar of an user in discord.js that doesn't share the same server

I have a small problem with my bot. For developing my bot, I made a new dev-bot which shares the same code as my normal bot, but has it's own token.
However, I ran into a small issue while developing.
I use this code, to get someones' avatar:
client.users.get(event.user.uid).avatarURL
This works fine on my normal but, however on my Dev-Bot I get this error message:
Error getting documents TypeError: Cannot read property 'AvatarURL' of undefined
I think it's due to the fact, that my Bot can't access the avatar of the user, because it doesn't share the same server/guild as this user.
Is there any workaround I could use?
Due to Discord.js and their way of caching, not all users are going to be cached in the bot. While there is a small possibility of it actually not knowing anything about the user, there is a large chance that the Discord API will still allow you to get information form it.
To fix this issue with caching in the latest master, we have to use Client.users, which returns a UserStore. Within the UserStore, we can use a method called fetch to get information about a user.
To fix this issue in the latest stable, we have to use a method called Client.fetchUser, which does the same thing but returns a User instead of a UserStore.
Please note this is only available using a bot account. Here's an example of its usage:
// Using Discord.js Stable
bot.fetchUser(theUsersID).then(myUser => {
console.log(myUser.avatarURL); // My user's avatar is here!
});
// Using Discord.js Master
bot.users.fetch(theUsersID).then(myUser => {
console.log(myUser.avatarURL()); // My user's avatar is here!
});
If there is an error fetching the user (say, a DiscordAPI Permissions Error), this means that there is no way for your bot to get the user's avatar without knowing who the user is first (or sharing a Guild with the user). Happy coding!

Categories

Resources