JSON-RPC 2.0 允许通知有一个错误响应?

JSON-RPC 2.0 allow Notifications to have an Error response?

阅读 JSON-RPC 2.0 规范后,我仍然不能 100% 确定:规范是否允许通知的发送者能够接收回错误对象?例如,如果 Notification 的接收者未能解析 Notification 的有效载荷,它是否可以回复说它解析失败?甚至不允许?

如果允许,那么错误对象响应是否需要 "id": null 或不存在?

谢谢。

亨利

是的,如果它不是有效的 JSON-RPC 请求,您应该以错误响应。

If there is not enough progression through the process to determine that the request object is a notification, it should default to normal request handling, which would include sending a response... which probably is also always an error.

Source

至于你问题的第二部分,是的,你必须包括"id": null

id

This member is REQUIRED. If there was an error in detecting the id in the Request object (e.g. Parse error/Invalid Request), it MUST be Null.

Source