gpt4 book ai didi

python - 使用 Autobahn Wamp Cra 时如何使用延迟返回身份验证密码?

转载 作者:太空宇宙 更新时间:2023-11-04 06:16:51 25 4
gpt4 key购买 nike

我正在继承 WampCraServerProtocol(来自 Autobahn Python)并覆盖 getAuthSecret。我知道现在我可以从那个方法返回一个延迟,但是,当做一个简单的测试时:

def getAuthSecret(self, authKey):        
deferred = Deferred()
deferred.callback("secret")
return deferred

...我的 WampCraClientProtocol 出现以下错误:

身份验证错误! http://api.wamp.ws/error#generic Deferred 实例没有属性 '__len__' None

好吧,光是这一点就已经令人困惑了。 getAuthSecret 返回的 deferred 是否有特殊要求?

好的,继续,基于那个错误,我向我要返回的延迟添加了一个(简单的)len 方法:

def getAuthSecret(self, authKey):
#secret_deferred = self.factory.get_secret(authKey)
deferred = Deferred()
deferred.__len__ = lambda: 1
deferred.callback("secret")
return deferred

...在那种情况下,我得到:

Authentication Error! http://api.wamp.ws/error#generic unsupported operand type(s) for +: 'instance' and 'str' None

这让我更加困惑。我只想知道从该方法返回延迟的正确方法。(我应该注意到,如果返回一个简单的简单字符串,一切都会完美无缺)。谢谢。

最佳答案

这对我有用:

https://github.com/tavendo/AutobahnPython/blob/master/examples/wamp/authentication/server.py#L72

您使用的是哪个 AutobahnPython 版本?

更新:

v0.5.9 有一个关于基于延迟的身份验证的错误(见下面的评论)。它已在 v0.5.14 上修复。基于 Wamp Cra 延迟的身份验证在该版本上运行良好。

关于python - 使用 Autobahn Wamp Cra 时如何使用延迟返回身份验证密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15035213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com