英文:
Client network socket disconnected before secure TLS connection was established Node.js v13.0.1
问题
I will provide the translation of the code section you provided. Here it is:
const functions = require('firebase-functions');
const firebase = require('firebase-admin');
var config = {
apiKey: "Your-API-Key",
authDomain: "fir-test-dc973.firebaseapp.com",
databaseURL: "https://fir-test-dc973.firebaseio.com/",
storageBucket: "gs://fir-test-dc973.appspot.com/"
};
firebase.initializeApp(config);
exports.create = functions.https.onRequest((req, res) => {
var data = JSON.parse(req.body);
var user_id = data.user_id;
var language_id = data.language_id;
firebase.database().ref("game_room/").orderByChild("availability").equalTo(1).limitToFirst(1).once('value', (snapshot) => {
console.log("user_id ", user_id);
if (snapshot.val() !== null) {
console.log("available");
var childKey = Object.keys(snapshot.val())[0];
console.log("gameroom ", childKey);
const userQuery = firebase.database().ref(`game_room/${childKey}`).once('value');
const language_id1 = userQuery.val().language_id;
if (language_id === language_id1) {
firebase.database().ref(`game_room/${childKey}/${user_id}`).update({
"status": true,
"right": 0,
"wrong": 0,
"que_no": 0,
"sel_ans": "",
});
firebase.database().ref(`game_room/${childKey}`).update({
"availability": 2,
});
} else {
createGameRoom();
}
console.log(snapshot.val());
} else {
createGameRoom();
}
});
function createGameRoom() {
console.log("not available");
var ref = firebase.database().ref('game_room/').push({
"availability": 1,
"language_id": language_id,
});
console.log(ref.key);
var key = ref.key;
console.log(key);
var ref1 = firebase.database().ref(`game_room/${key}/${user_id}`).update({
"status": true,
"right": 0,
"wrong": 0,
"que_no": 0,
"sel_ans": "",
});
}
res.send({"code": user_id});
});
Please note that you should replace "Your-API-Key"
in the config
object with your actual Firebase API key.
英文:
When id add exports.create=functions.https.onRequest((req,res)=> and run command firebase deploy shows this result
functions: Finished running predeploy script.
i functions: ensuring necessary APIs are enabled...
+ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (40.37 KB) for uploading
! functions: Upload Error: Server Error. Client network socket disconnected before secure TLS connection was established
Error: Server Error. Client network socket disconnected before secure TLS connection was established
please check the code below.....
const firebase = require('firebase-admin');
var config = {
apiKey: "AIzaSyAzf0Y4k7qvkWSWkwgsYjH9mrnFa_P9xt4",
authDomain: "fir-test-dc973.firebaseapp.com",
databaseURL: "https://fir-test-dc973.firebaseio.com/",
storageBucket: "gs://fir-test-dc973.appspot.com/"
};
firebase.initializeApp(config);
exports.create=functions.https.onRequest((req,res)=>{
var data=JSON.parse(req.body);
var user_id=data.user_id;
var language_id=data.language_id;
firebase.database().ref("game_room/").orderByChild("availability").equalTo(1).limitToFirst(1).once('value', ((snapshot)=> {
console.log("user_id ",user_id);
if (snapshot.val() !== null) {
console.log("available");
var childKey = Object.keys(snapshot.val());
console.log("gameroom ", childKey);
const userQuery = firebase.database().ref(`game_room/${childKey}`).once('value');
const language_id1 = userQuery.val().language_id;
if (language_id === language_id1) {
firebase.database().ref(`game_room/${childKey}/${user_id}`).update({
"status": true,
"right": 0,
"wrong": 0,
"que_no": 0,
"sel_ans": "",
});
firebase.database().ref(`game_room/${childKey}`).update({
"availability": 2,
});
}else{
createGameRoom();
}
console.log(snapshot.val());
}
else
{
createGameRoom();
}
}));
function createGameRoom() {
console.log("not available");
var ref=firebase.database().ref('game_room/').push({
"availability":1,
"language_id":language_id,
});
console.log(ref.key);
var key=ref.key;
console.log(key);
var ref1= firebase.database().ref(`game_room/${key}/${user_id}`).update({//.push({
//ref.set({
"status":true,
"right":0,
"wrong":0,
"que_no":0,
"sel_ans":"",
});
}
res.send({"code":user_id});
});```
log is here
[debug] [2020-01-03T13:50:53.722Z] <<< HTTP RESPONSE 200
[debug] [2020-01-03T13:50:53.725Z] >>> HTTP REQUEST PUT https://storage.googleapis.com/gcf-upload-us-central1-46ce5050-804a-4464-a2b2-569f0e4aaa93/75a761e4-936f-4b66-8f59-bb043b386f8d.zip?GoogleAccessId=service-853915451227@gcf-admin-robot.iam.gserviceaccount.com&Expires=1578061220&Signature=KBV5Gmv3OObNlC8%2BuCwYptBWjPI%2BhGblYX644ugU15FPwwFITQ3VDSIM7%2F9xsK2UqjFhdjx8s2inymbffxoemRmN1mKqPbHGP0ZFCy%2FDQUAHR%2FUccF%2FtRBiG2EQ0oaU5m9T7NoTs1NnVmDNhGz25mIGNdkO0efv8ZOqfXCYOSLV1jbgQtUGv%2FB%2ButjsTB3b6nxBOwHj7HbsFt1pB4uqGmVitGxj0JvxOhSAK6pCWXrsbWgL%2FnnoktYhhyMWFt9YgTSdWB36OeigQCdVldRVIodpaa3aShfDwMRPQCktgQQWZX0tAPsScs62i5Y11PLvSk2VeGxFFZgAyEA1XrzPjyg%3D%3D
<request body omitted>
[warn] ! functions: Upload Error: Server Error. Client network socket disconnected before secure TLS connection was established
[debug] [2020-01-03T13:51:04.100Z] Error: Client network socket disconnected before secure TLS connection was established
at connResetException (internal/errors.js:575:14)
at TLSSocket.onConnectEnd (_tls_wrap.js:1361:19)
at Object.onceWrapper (events.js:299:28)
at TLSSocket.emit (events.js:215:7)
at TLSSocket.EventEmitter.emit (domain.js:478:20)
at endReadableNT (_stream_readable.js:1198:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
[error]
[error] Error: Server Error. Client network socket disconnected before secure TLS connection was established
</details>
# 答案1
**得分**: 1
似乎在部署过程中发生了某种网络错误。当CLI生成类似这样不提供明确解决方案的错误消息时,您应该直接[联系 Firebase 支持][1]进行故障排除。
[1]: https://support.google.com/firebase/contact/support
<details>
<summary>英文:</summary>
It looks like you might have had some sort of network error during deployment. When the CLI generates error messages like this that don't offer a clear resolution, you should [contact Firebase support directly][1] for troubleshooting.
[1]: https://support.google.com/firebase/contact/support
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论