Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

聊天机器人接口调用报错 #113

Open
halfray opened this issue Oct 16, 2024 · 2 comments
Open

聊天机器人接口调用报错 #113

halfray opened this issue Oct 16, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@halfray
Copy link

halfray commented Oct 16, 2024

报错日志如下:

2024-10-16 13:36:22.388 [nioEventLoopGroup-3-828] DEBUG org.apache.http.wire - http-outgoing-295 << "HTTP/1.1 200 OK[\r][\n]"
2024-10-16 13:36:22.389 [nioEventLoopGroup-3-828] DEBUG org.apache.http.wire - http-outgoing-295 << "Server: nginx[\r][\n]"
2024-10-16 13:36:22.389 [nioEventLoopGroup-3-828] DEBUG org.apache.http.wire - http-outgoing-295 << "Date: Wed, 16 Oct 2024 05:36:22 GMT[\r][\n]"
2024-10-16 13:36:22.390 [nioEventLoopGroup-3-828] DEBUG org.apache.http.wire - http-outgoing-295 << "Content-Type: application/json; charset=utf-8[\r][
\n]"
2024-10-16 13:36:22.390 [nioEventLoopGroup-3-828] DEBUG org.apache.http.wire - http-outgoing-295 << "Content-Length: 271[\r][\n]"
2024-10-16 13:36:22.391 [nioEventLoopGroup-3-828] DEBUG org.apache.http.wire - http-outgoing-295 << "Connection: keep-alive[\r][\n]"
2024-10-16 13:36:22.391 [nioEventLoopGroup-3-828] DEBUG org.apache.http.wire - http-outgoing-295 << "Access-Control-Allow-Origin: *[\r][\n]"
2024-10-16 13:36:22.391 [nioEventLoopGroup-3-828] DEBUG org.apache.http.wire - http-outgoing-295 << "Access-Control-Expose-Headers: WWW-Authenticate,Se
rver-Authorization[\r][\n]"
2024-10-16 13:36:22.392 [nioEventLoopGroup-3-828] DEBUG org.apache.http.wire - http-outgoing-295 << "Vary: Origin[\r][\n]"
2024-10-16 13:36:22.392 [nioEventLoopGroup-3-828] DEBUG org.apache.http.wire - http-outgoing-295 << "X-Powered-By: Express[\r][\n]"
2024-10-16 13:36:22.393 [nioEventLoopGroup-3-828] DEBUG org.apache.http.wire - http-outgoing-295 << "[\r][\n]"
2024-10-16 13:36:22.393 [nioEventLoopGroup-3-828] DEBUG org.apache.http.wire - http-outgoing-295 << "{"message":"No matching document found for id "67
0f50d514f731dfce1a00d1" version 0 modifiedPaths "lastMessageSentAt, history, pendingTopic, currentTopic"","name":"VersionError","version":0,"modifie
dPaths":["lastMessageSentAt","history","pendingTopic","currentTopic"]}"
2024-10-16 13:36:22.393 [nioEventLoopGroup-3-828] DEBUG org.apache.http.headers - http-outgoing-295 << HTTP/1.1 200 OK
2024-10-16 13:36:22.394 [nioEventLoopGroup-3-828] DEBUG org.apache.http.headers - http-outgoing-295 << Server: nginx
2024-10-16 13:36:22.394 [nioEventLoopGroup-3-828] DEBUG org.apache.http.headers - http-outgoing-295 << Date: Wed, 16 Oct 2024 05:36:22 GMT
2024-10-16 13:36:22.394 [nioEventLoopGroup-3-828] DEBUG org.apache.http.headers - http-outgoing-295 << Content-Type: application/json; charset=utf-8
2024-10-16 13:36:22.395 [nioEventLoopGroup-3-828] DEBUG org.apache.http.headers - http-outgoing-295 << Content-Length: 271
2024-10-16 13:36:22.396 [nioEventLoopGroup-3-828] DEBUG org.apache.http.headers - http-outgoing-295 << Connection: keep-alive
2024-10-16 13:36:22.396 [nioEventLoopGroup-3-828] DEBUG org.apache.http.headers - http-outgoing-295 << Access-Control-Allow-Origin: *
2024-10-16 13:36:22.396 [nioEventLoopGroup-3-828] DEBUG org.apache.http.headers - http-outgoing-295 << Access-Control-Expose-Headers: WWW-Authenticate,
Server-Authorization
2024-10-16 13:36:22.397 [nioEventLoopGroup-3-828] DEBUG org.apache.http.headers - http-outgoing-295 << Vary: Origin
2024-10-16 13:36:22.397 [nioEventLoopGroup-3-828] DEBUG org.apache.http.headers - http-outgoing-295 << X-Powered-By: Express
2024-10-16 13:36:22.397 [nioEventLoopGroup-3-828] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection can be kept alive indefinitely
2024-10-16 13:36:22.398 [nioEventLoopGroup-3-828] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-295: set socket ti
meout to 0
2024-10-16 13:36:22.398 [nioEventLoopGroup-3-828] DEBUG org.apache.http.impl.execchain.MainClientExec - Cancelling request execution
2024-10-16 13:36:22.400 [nioEventLoopGroup-3-828] ERROR com.snl.exception.SocketMessagExceptionListener - org.json.JSONException: JSONObject["rc"] not
found.
com.corundumstudio.socketio.handler.SocketIOException: org.json.JSONException: JSONObject["rc"] not found.
at com.corundumstudio.socketio.annotation.OnEventScanner$2.onData(OnEventScanner.java:104) ~[netty-socketio-1.7.19.jar!/:?]
at com.corundumstudio.socketio.namespace.Namespace.onEvent(Namespace.java:147) [netty-socketio-1.7.19.jar!/:?]

....

Caused by: org.json.JSONException: JSONObject["rc"] not found.
at org.json.JSONObject.get(JSONObject.java:570) ~[json-20230227.jar!/:?]
at org.json.JSONObject.getInt(JSONObject.java:742) ~[json-20230227.jar!/:?]
at com.chatopera.bot.sdk.Chatbot.purge(Chatbot.java:1067) ~[sdk-3.5.2.jar!/:?]
at com.chatopera.bot.sdk.Chatbot.command(Chatbot.java:223) ~[sdk-3.5.2.jar!/:?]

@halfray halfray added the bug Something isn't working label Oct 16, 2024
@hailiang-wang
Copy link
Member

hailiang-wang commented Oct 16, 2024

这句是错误的返回信息:

0f50d514f731dfce1a00d1" version 0 modifiedPaths "lastMessageSentAt, history, pendingTopic, currentTopic"","name":"VersionError","version":0,"modifie
dPaths":["lastMessageSentAt","history","pendingTopic","currentTopic"]}"

请求 API 是不是 多轮对话检索 API ?

Chatbot#command("POST", "/conversation/query", body)

这个返回中,没有 rc 字段而引起了 SDK 报错,
但是本身这个返回值就是因为 No matching document found for id "670f50d514f731dfce1a00d1

推测引起错误的原因

是不是在多轮对话脚本中,去检索了一个 FAQ 知识库问答对,但是该知识库问答对已经被删除了,因为这个问答对不存在。

经过进一步分析,该原因是 Mongodb 保存的时候,出现问题。
https://blog.csdn.net/daxianghaoshuai/article/details/81155627
https://geek-docs.com/mongodb/mongodb-questions/409_mongodb_versionerror_no_matching_document_found_error_on_nodejsmongoose.html

进一步的优化返回值

该 API 调用,针对任何情况都要返回 RC,如果逻辑执行正常,RC 为 0;如果发生异常,则 RC 为某个正整数,不同正整数代表错误含义。

这次 API 调用的问题在于没有返回 RC,目前需要进一步了解,何种情况下发生 No matching document found for id "xxx"

临时解决方案

使用 catch 捕获异常,并且识别没有 rc 字段的情况下,认为机器人没有得到有效的回复。

@hailiang-wang
Copy link
Member

@halfray 这个问题基本锁定是 MongoDB 存储导致,目前尚未能重现。
您后来继续遇到了吗?如何进行问题重现呢?

是不是在您保存多轮对话以后,出现的?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants