python - 对 Mongodb 和 Postgresql 凭证感到困惑
问题描述
我正在研究 4 年前给我的一个旧的 unity3d 项目。运行游戏所需的前端和后端服务器。前端需要 Postgres 数据库,后端需要 Mongodb 和 Postgresql 我能够将所有文件从 2.7 配置到 Python 3.9 并运行两个服务器。我能够登录到 postgresql 和 mongodb。配置数据库连接,一切正常。尝试登录游戏时出现以下错误:
root@vps-99083:/home/Latestfiles/frontend_server# Database exception while getting session: TypeError('Secret key missing for non-string Cookie.',); ignored.
auth for user test1 with hash 098f6bcd4621d373cade4e832627b4f6 (got 098f6bcd4621d373cade4e832627b4f6)
test1 authenticating with client version 0.3.0.4...
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/bottle.py", line 862, in _handle
return route.call(**args)
File "/usr/local/lib/python3.6/dist-packages/bottle.py", line 1729, in wrapper
rv = callback(*a, **ka)
File "/usr/local/lib/python3.6/dist-packages/bottle_sqlalchemy.py", line 155, in wrapper
rv = callback(*args, **kwargs)
File "/home/Latestfiles/frontend_server/sessions.py", line 72, in wrapper
return func(sess, user, *a, **k)
File "/home/Latestfiles/frontend_server/metrics.py", line 24, in wrapper
d = func( *a, **k )
File "frontend.py", line 943, in login
d = finalizeLogin( db, session, user, clientversion, clientplatform, screenName=user.username)
File "frontend.py", line 442, in finalizeLogin
session.user_id = user.id
AttributeError: 'NoneType' object has no attribute 'user_id'
108.14.69.202 - - [2021-06-22 19:03:11] "POST /login HTTP/1.1" 500 885 0.603911
finalizeLogin 如下。它是否与编码或我对 postgresql 和 mongodb 的配置有关。
def finalizeLogin( db, session, user, clientversion, clientplatform, screenName = None ):
# print("Authentication OK user=" + str(user) + " sessuser=" + str(sessions.getUserById(user.id)))
session.user_id = user.id
user.is_online = True
sessions.setUserById(user.id, UserState.UserState(user.username, db))
user = sessions.getUserById(user.id)
user.login(clientversion, clientplatform)
if screenName is not None:
user.screenname = screenName
discoveryEngine.endMatchmaking( user )
discoveryEngine.removeWithUsername( user.username )
if not messageCenter.userLogin(user.username, user.screenname, user.id ):
# insurance here
messageCenter.userLogout(user.username)
messageCenter.userLogin(user.username, user.screenname, user.id)
messageCenter.userJoinChannel(user.username, "General")
db.commit()
d = {}
d["username"] = user.screenname
d["screenname"] = user.screenname
d["clantag"] = user.clantag
d["is_admin"] = True if user.account_type == 9 else False
d["ping_delay"] = CLIENT_PING_DELAY
d["message_delay"] = CLIENT_MESSAGE_DELAY
d["friend_delay"] = CLIENT_FRIEND_STATUS_DELAY
clear_matchreqs_for_user(db, user)
我的 pg_hba.conf:
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
host all all all md5
local postgres postgres peer
解决方案
推荐阅读
- android - Android Studio 卡在安装 APK,adb 有时无法安装 APK,不知为何 Android Studio 干扰了 adb 的 install 命令
- javascript - 单击 ID 不可用的按钮
- javascript - javascript 导入、导出:简单示例失败
- java - 如何使比较器正常工作,现在它给出了错误的字符串长度
- rust - 如何获取对 RwLock 内对象的引用?
- kotlin - Webflux,基于 Reactive Publisher 的流程在中间被打断
- r - 对数据框的每一行应用 agrep 函数
- css - “数字”类型的输入字段未在 Wordpress 的联系表 7 中显示任何文本
- matlab - 如何针对另一个不同大小的日期时间列表对日期时间列表进行逻辑测试?MATLAB
- javascript - 如何在返回结果中创建新字段并根据使用 Mongoose 的条件在其中设置值?