我使用OrientJs通過node.js與OrientDB進行通信。 我已經實現了一個API來插入一個新的用戶到數據庫,在檢查他是否存在。OrienDb.RequestError:發現未知會話x
var dbServer = OrientDB({
host: 'localhost',
port: 2424,
username: 'root',
password: 'password'
});
// Connect to db 'test'
var db = dbServer.use({
name: 'mydbtest',
username: 'root',
password: 'my_root_password'
})
// Set the server...
app.post('/insertUser/', function (req, res) {
let username = req.body.username
let password = req.body.password
//Checks on username and password ...
let fetcher = require('../fetcher/fetcher')
fetcher.userExists(db, username, password).then(function (exists) {
console.log(exists) //exists = true/false
if (!exists) {
db.open().then(
db.let('user', function (user) {
user.create('vertex', 'User')
.set({
username: username,
password: password
})
}).commit().return('$user').one().then(function (result) {
db.close()
if (!result.undefined) { res.status(200).send(true) }
else { res.status(200).send(false) }
}).catch(function (e) { // The error is caught here
db.close()
console.error(e);
res.status(500).send({ message: 'Unable to save new user1' })
})
).catch(function (e) {
db.close()
res.status(500).send({ message: 'Unable to save new user' })
})
}
else res.status(200).send(false)
})
})
哪裏fetcher.userExists(db, username, password)
是,返回true,如果用戶確實存在,否則爲false的功能。 當調用從郵差THI API,我收到此錯誤消息:
{ OrientDB.RequestError
at child.Operation.parseError (C:\Users\sdp\node_modules\orientjs\lib\transport\binary\protocol33\operation.js:896:13)
at child.Operation.consume (C:\Users\sdp\node_modules\orientjs\lib\transport\binary\protocol33\operation.js:487:35)
at Connection.process (C:\Users\sdp\node_modules\orientjs\lib\transport\binary\connection.js:410:17)
at Connection.handleSocketData (C:\Users\sdp\node_modules\orientjs\lib\transport\binary\connection.js:301:20)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:252:12)
at readableAddChunk (_stream_readable.js:239:11)
at Socket.Readable.push (_stream_readable.js:197:10)
at TCP.onread (net.js:588:20)
name: 'OrientDB.RequestError',
message: 'Found unknown session 13',
data: {},
previous: [],
id: 1,
type: 'com.orientechnologies.common.io.OIOException',
hasMore: 0 }
該消息是Found unknown session 13
,但它由2每個I調用服務時間增加的數量。
如果我把代碼中if(!exists){}
聲明出來fetcher.userExists(db, username, password).then(function (exists) {..
的then
塊的正常工作,但這樣做,如果用戶存在,我可以檢查。我可以弄清楚是什麼問題。有人能幫我嗎?謝謝。
注:我使用OrientDB社區2.2.24
嗨,是否有可能您的會話過期或臨時斷開? –