`socket write error` or `closed by server` is reported for a connection

2024-04-01 09:12:16  Updated

Symptom

When you connect to an ODP, ODC frequently prompts that the connection has been interrupted. However, the issue does not occur when you directly connect to an OBServer node.

The following error messages may be returned:

  • Connection reset by peer: socket write error

  • unexpeted end of steam, read 0 bytes from 4(socket was closed by server)

Possible causes

If the ODP is configured with a persistent connection and user_timeout is set to a smaller value, when packet loss occurs, the ACK packet may not be returned for the keepalive packet. In this case, the ODP disconnects the connection when the timeout period expires.

Packet capture example:

3

Solutions

  1. Modify the persistent connection configuration of the ODP to ensure that:

    • The persistent connection feature is enabled: client_sock_option_flag_out=2

    • The value of client_tcp_user_timeout is set. We recommend that you set this parameter to 0, or at least a value greater than that of client_tcp_keepintvl.

      Notice

      • To modify the ODP configuration, you must use the root@proxysys account. Otherwise, the modification becomes invalid.
      • You can modify the configuration of an ODP in an ODP cluster managed by OceanBase Cloud Platform (OCP) in OCP.

    The following table describes the parameters for configuring TCP connection keepalive for the ODP.

    Parameter Description
    client_sock_option_flag_out The client-side socket option. Valid values: bit 1: NO_DELAY; bit 2: KEEP_ALIVE.
    client_tcp_keepidle The keepalive duration.
    client_tcp_keepintvl The interval for sending a keepalive packet.
    client_tcp_keepcnt The threshold of the unreceived number of keepalive packets for determining a connection as disconnected.
    client_tcp_user_timeout The timeout period for waiting for the TCP-layer ACK message. If this period expires, ODP disconnects the connection.

    Notice

    The value of this parameter must be greater than the value of client_tcp_keepintvl. We recommend that you set this parameter to 0 for ODP. Otherwise, the connection may be interrupted by ODP in poor network conditions (such as in the case of packet loss).

  2. Use the CLI tool OBClient to view the current configuration and connect to the ODP by using the root@proxysys account.

    -- View the current configuration.
    show proxyconfig like 'client_sock_option_flag_out';
    show proxyconfig like 'client_tcp%';
    
  3. We recommend that you use the following configuration:

    alter proxyconfig set client_sock_option_flag_out=2
    alter proxyconfig set client_tcp_keepidle=5
    alter proxyconfig set client_tcp_keepintvl=5
    alter proxyconfig set client_tcp_keepcnt=5
    alter proxyconfig set client_tcp_user_timeout=0
    

Contact Us