【发布时间】:2018-12-24 05:58:06
【问题描述】:
当我对 ejabberd API 使用以下命令时,我得到以下响应;
curl -ik -X POST -H 'Authorization: Bearer xxxxxxxxxxx' https://localhost:5280/api/set_vcard -d '{"user":"foo","host":"example.com","name":"FN","content":"foobar"}'
HTTP/1.1 400 Bad Request
Content-Length: 18
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type, Authorization, X-Admin
"database_failure"
在 ejabberd 日志(5 级)上我看到了这个;
[info] (<0.607.0>) Accepted connection ::ffff:172.18.0.1:46622 -> ::ffff:172.18.0.3:5280
[debug] S: [{[<<"ws">>],ejabberd_http_ws},{[<<"bosh">>],mod_bosh},{[<<"oauth">>],ejabberd_oauth},{[<<"api">>],mod_http_api},{[<<"admin">>],ejabberd_web_admin}]
[debug] ({tlssock,#Port<0.18819>,#Ref<0.650175335.3240493057.203147>}) http query: 'POST' <<"/api/set_vcard">>
[debug] client data: <<"{\"user\":\"foo\",\"host\":\"example.com\",\"contents\":[\"FN:foobar\"]}">>
[debug] [<<"api">>,<<"set_vcard">>] matches [<<"api">>]
[info] API call set_vcard [{<<"user">>,<<"foo">>},{<<"host">>,<<"example.com">>},{<<"contents">>,[<<"FN:foobar">>]}] from ::ffff:172.18.0.1:46622
[debug] Command 'set_vcard' execution allowed by rule 'api service' (CallerInfo=#{caller_module => mod_http_api,caller_server => <<"example.com">>,ip => {0,0,0,0,0,65535,44050,1},oauth_scope => [<<"ejabberd:api-service">>],usr => {<<"admin">>,<<"example.com">>,<<>>}})
[debug] Executing command mod_admin_extra:set_vcard with Args=[<<"foo">>,<<"example.com">>,<<>>,<<>>,[<<"FN:foobar">>]]
它使用 MySQL 作为数据库(其他一切都可以正常工作)但是当我查看数据库一般查询日志时,我没有看到我的 API 请求触发任何查询。我看到所有其他正常的 ejabberd 查询,因此数据库连接没有问题,并且如前所述,其他一切正常。
$ ejabberdctl status
The node ejabberd@e87da11aa894 is started with status: started
ejabberd 18.4.0 is running in that node
有没有人有任何线索可以让我摆脱困境?我已经没有关于可能是什么问题的线索了。
!!!编辑!!!
解决方法
正如https://github.com/processone/ejabberd/issues/2629 中提到的,其他人也遇到过这个问题。更改配置以禁用缓存并清除数据库中的 vcard 表似乎是一种解决方法;
SQL:
DELETE FROM vcard;
配置:
...
mod_vcard:
search: false
use_cache: false
...
【问题讨论】:
-
在 github (github.com/processone/ejabberd/issues/2629) 中创建问题后,事实证明关闭缓存可以解决问题。 mod_vcard:搜索:假使用缓存:假
标签: ejabberd