The error zx_err_peer_closed
indicates a failed attempt to read or write from a peered Zircon object. Usually, this means that the remote side of the peer is closed. This can occur for many different types of Zircon objects, including:
The error can also occur when failing to signal a peered object, such as zx_object_signal_peer
.
This document helps you troubleshoot the following causes of a zx_err_peer_closed
error.
The following are potential causes of a zx_err_peer_closed
error.
The zx_err_peer_closed
error is thrown when incompatible FIDL protocols are used between the client and server, which closed the connection.
To remedy this, make sure your client and server are using the same FIDL protocols. See the FIDL language specification for more information on FIDL protocols.
Similar to incompatible FIDL protocols, if the requested protocol is not defined in your component manifest, you will get a zx_err_peer_closed
error.
Specifically, if you are using legacy components, you will get a zx_err_peer_closed
error in the following cases:
If this is the case, make sure your manifest file includes the protocol that you are requesting. You can use fidlcat
to help you diagnose the missing protocol.
For more information, see:
fidlcat
.The zx_err_peer_closed
error is thrown when you fail to open a file. This can happen for the following reasons:
If this is the case, verify that you are requesting an existing file, or that the file and directory have the appropriate rights. You can learn more about directory rights and how they're specified.
If the peer crashes, the system processes the crash and terminates the process that generated the error and all associated objects, leading to a zx_err_peer_closed
error.
You can view logs to confirm if the peer has crashed. If this is the case, you can debug the peer using the Just in Time Debugger to find the source of the crash, and try the operation again.
As a component author, it's important to help users get additional meaningful error messages when they see the zx_err_peer_closed
error. To do this, your code should set an epitaph with the binding::Close(zx_status_t epitaph_value) binding.
See examples for setting meaninful epitaphs in //src/sys/appmgr/realm.cc.