Dp read() Broken pipe (Write failed)

We are trying to register a action callback with xml configuration.

While trying the dp.read(); getting the IO exception : Broken pipe (Write failed)

During this time any cli action throws application communication failure

Here is the log

localhost java.net.SocketException: Broken pipe (Write failed)

localhost at java.net.SocketOutputStream.socketWrite0(Native Method)

localhost at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)

localhost at java.net.SocketOutputStream.write(SocketOutputStream.java:155)

localhost at com.tailf.proto.ConfOutputStream.writeTo(ConfOutputStream.java:174)

localhost at com.tailf.conf.ConfInternal.termWrite(ConfInternal.java:926)

localhost at com.tailf.conf.ConfInternal.termWrite(ConfInternal.java:1053)

localhost at com.tailf.dp.Dp.replyError(Dp.java:2872)

localhost at com.tailf.dp.Dp.replyError(Dp.java:2855)

localhost at com.tailf.dp.Dp.read(Dp.java:2711)

Here is the sample of the code - similar to api.

To register a data callback in ConfD, we can do:

// int port = Conf.PORT for ConfD or Conf.NCS_PORT for NCS

Socket ctrl_socket= new Socket(“127.0.0.1”, port);

final Dp dp = new Dp(“server_daemon”, ctrl_socket);

dp.registerAnnotatedCallbacks(new SimpleTransCb());

dp.registerAnnotatedCallbacks(new SimpleDataCb());

dp.registerDone();

Thread dpTh = new Thread(new Runnable() {

   public void run() {

       try {

           while (true) dp.read();

       } catch (Exception e) {

           e.printStackTrace();

           return;

       }

   }

});

dpTh.start();

The code is stable and working so far . We are getting this error for first time.

Any input is really helpful to analysis the code further

You likely likely get this error since the application is writing to a connection, the control socket, when the other end, ConfD, has already closed the control socket for some reason.

To find out why the control socket was closed by ConfD see the developer log.

Thank you cohult for the information
Will check the logs for more details

I don’t have developer log since the issue happening in production

Here is the log details

Feb 23 16:01:54 confd[8620]: devel-c Worker socket query timed out daemon ‘server_daemon’ id 3

Feb 23 16:01:54 confd[8620]: - Daemon server_daemon timed out

Feb 23 16:01:54 confd[8620]: devel-c action action() error {external_timeout, “”} for callpoint ‘ssl-action’ path /ssl:ssl/inline
Feb 23 16:01:54 confd[8620]: devel-c action action() error {external_timeout, “”} for callpoint ‘ssl-action’ path /ssl:ssl/inline
Feb 23 16:01:54 confd[8620]: devel-c action action() error {external_timeout, “”} for callpoint ‘ssl-action’ path /ssl:ssl/inline
Feb 23 16:01:54 confd[8620]: devel-c action action() error {external_timeout, “”} for callpoint ‘ssl-action’ path /ssl:ssl/inline

what could be the reason confd can close the control socket ?
Based on the above example is there way to reproduce the issue?

can you provide some input …

There is /confdConfig/capi/queryTimeout (default 120 seconds) set by confd.conf or by the application that registered for the action/callpoint using confd_action_set_timeout() that expired.
Check the application that handles that action for why it does not reply before the query timeout expires and ConfD, therefore, closes the socket.

See the confd.conf(5) man page for details on the /confdConfig/capi/queryTimeout setting and the confd_lib_dp(3) man page for details on the confd_action_set_timeout()

I have checked the confd.conf but we don’t have /confdConfig/capi/queryTimeout and application also not setting the timeout

I have tried to simulate the EOF with the following command

socat TCP-LISTEN:4575,fork TCP:127.0.0.1:4565

I was not able to reproduce the socket close .

bash-4.2# netstat -tulpn | grep confd
tcp 0 0 0.0.0.0:2022 0.0.0.0:* LISTEN 4671/confd
tcp 0 0 127.0.0.1:2023 0.0.0.0:* LISTEN 4671/confd
tcp 0 0 0.0.0.0:8008 0.0.0.0:* LISTEN 4671/confd
tcp 0 0 127.0.0.1:4565 0.0.0.0:* LISTEN 4671/confd
tcp6 0 0 :::2022 :::* LISTEN 4671/confd
tcp6 0 0 :::2023 :::* LISTEN 4671/confd
tcp6 0 0 :::8008 :::* LISTEN 4671/confd
udp 0 0 0.0.0.0:161 0.0.0.0:* 4671/confd
udp6 0 0 :::161 :::* 4671/confd

Is there a way to simulate the socket close ?

Default is 120s.

Set a sleep() in your application’s action callback function for 121 seconds and when the sleep() returns send the reply from the action callback function.