Swoole Server getLastError

Declaration

<?php
Swoole\Server->getLastError(): int

Parameters

none

Return

success

If successful, a integer is returned which corresponds to an error code and message.

Description

Get the error code of the most recent error.

Returns the error code of the most recent error. Allows you to execute different logic based on the error code returned.

Error Codes

The following are the different error codes which can be returned:

  • 1001: The connection has been closed by the server.
  • 1002: The connection has been closed by the client side.
  • 1003: The connection is closing.
  • 1004: The connection is closed.
  • 1005: The connection does not exist or incorrect $fd was given.
  • 1007: Received data after connection has been closed already. Data will be discarded.
  • 1008: The send buffer is full, cannot perform any further send operations as buffer is full.
  • 1202: The data sent exceeds the buffer_output_size configuration option.
  • 9007: Only for dispatch_mode 3, indicates that the process is not currently available.