A connection has been closed by React
@param \React\Socket\ConnectionInterface $conn
485863
public function handleEnd($conn) {
        try {
            $this->app->onClose($conn->decor);
        } catch (\Exception $e) {
            $this->handleError($e, $conn);
        }

        unset($conn->decor);
    }
734384
private function parseConn($conn)
    {
        while(true)
        {
            $meta = fread($conn, 4);
            if('' === $meta || false === $meta)
            {
                return;
            }
            $length = unpack('N', $meta)[1];
            $data = fread($conn, $length);
            if(false === $data || !isset($data[$length - 1]))
            {
                return;
            }
            $body = ($this->unserialize)($data);
            if(!$body instanceof Operation)
            {
                return;
            }
            try{
                $result = new Result($this->operationParser->parse($body));
            } catch(\Throwable $th) {
                $result = new Result(null, $th);
            }
            $resultData = ($this->serialize)($result);
            $length = strlen($resultData);
            $resultData = pack('N', $length) . $resultData;
            fwrite($conn, $resultData, $length + 4);
        }
    }
1186295
public function onClose(ConnectionInterface $conn) {

        // The connection is closed, remove it, as we can no longer send it messages
        $this->clients->detach($conn);

        // pulled data from queues
        $data = $this->queueService->pull([
            // identity for open queue message
                'hash'        =>  md5($this->getIpAddress($conn).$this->getUserAgent($conn)),
            ], function($response) use ($conn) {

            return array_merge($response, [
                'ua'            => $this->getUserAgent($conn),
                'language'      => $this->getLanguage($conn),
                'location'      => $this->getLocation($conn),
                'close'         => time()
            ]);
        });

        // save data to storage
        $this->storageService->add($data);

        echo Messenger::close($this->getIpAddress($conn));

        // end profiler
        if(defined('SONAR_VERBOSE') === true) {
            Profiler::finish();
            Profiler::getProfilingData();
        }
    }
326117
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;


         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(FunctionPhaseTableMap::COL_ID)) {
            $modifiedColumns[':p' . $index++]  = '`id`';
        }
        if ($this->isColumnModified(FunctionPhaseTableMap::COL_TYPE)) {
            $modifiedColumns[':p' . $index++]  = '`type`';
        }
        if ($this->isColumnModified(FunctionPhaseTableMap::COL_SKILL_ID)) {
            $modifiedColumns[':p' . $index++]  = '`skill_id`';
        }
        if ($this->isColumnModified(FunctionPhaseTableMap::COL_TITLE)) {
            $modifiedColumns[':p' . $index++]  = '`title`';
        }

        $sql = sprintf(
            'INSERT INTO `kk_trixionary_function_phase` (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case '`id`':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case '`type`':
                        $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
                        break;
                    case '`skill_id`':
                        $stmt->bindValue($identifier, $this->skill_id, PDO::PARAM_INT);
                        break;
                    case '`title`':
                        $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        $this->setNew(false);
    }
768775
public function onMessage(ConnectionInterface $conn, $input)
    {
        $this->console->comment(sprintf('Message from %d: %s', $conn->resourceId, $input));

        if ($this->isThrottled($conn, 'onMessage')) {
            $this->console->info(sprintf('Message throttled: %d', $conn->resourceId));
            $this->send($conn, trans('ratchet::messages.tooManyMessages'));
            $this->throttled = true;

            if (config('ratchet.abortOnMessageThrottle')) {
                $this->abort($conn);
            }
        }
    }
1237187
public void releaseConnection (String ident, boolean readOnly, Connection conn)
    {
        try {
            conn.close();
        } catch (Exception e) {
            log.warning("Failure closing connection",
                        "ident", ident, "ro", readOnly, "conn", conn, e);
        }
    }
164061
public function postDelete(ConnectionInterface $con = null)
    {
        parent::postDelete($con);

        $this->dispatchEvent(TheliaEvents::AFTER_DELETEADDRESS, new AddressEvent($this));
    }
461428
public function onSlaveClosed(ConnectionInterface $connection)
    {
        if ($this->status === self::STATE_SHUTDOWN) {
            return;
        }

        try {
            $slave = $this->slaves->getByConnection($connection);
        } catch (\Exception $e) {
            // this connection is not registered, so it died during the ProcessSlave constructor.
            $this->output->writeln(
                '<error>Worker permanently closed during PHP-PM bootstrap. Not so cool. ' .
                'Not your fault, please create a ticket at github.com/php-pm/php-pm with ' .
                'the output of `ppm start -vv`.</error>'
            );

            return;
        }

        // remove slave from reload killer pool
        unset($this->slavesToReload[$slave->getPort()]);

        // get status before terminating
        $status = $slave->getStatus();
        $port = $slave->getPort();

        if ($this->output->isVeryVerbose()) {
            $this->output->writeln(sprintf('Worker #%d closed after %d handled requests', $port, $slave->getHandledRequests()));
        }

        // kill slave and remove from pool
        $this->terminateSlave($slave);

        /*
         * If slave is in registered state it died during bootstrap.
         * In this case new instances should only be created:
         * - in debug mode after file change detection via restartSlaves()
         * - in production mode immediately
         */
        if ($status === Slave::REGISTERED) {
            $this->bootstrapFailed($port);
        } else {
            // recreate
            $this->newSlaveInstance($port);
        }
    }
1062192
public function markConnBusy(ClientConnection $conn, $url)
    {
        if (!isset($this->servConnFree[$url])) {
            return;
        }
        $this->servConnFree[$url]->detach($conn);
    }
700528
public function handleConnect($server, $socket)
    {
        $socket->conn = new NetworkConnection($socket);

        try
        {
            $this->component->handleConnect($socket->conn);

            $socket->on('data',  [ $this, 'handleData' ]);
            $socket->on('error', [ $this, 'handleError' ]);
            $socket->on('close', [ $this, 'handleDisconnect' ]);
        }
        catch (Error $ex)
        {
            $this->close($socket);
        }
        catch (Exception $ex)
        {
            $this->close($socket);
        }
    }
861422
public final void closeConnection(final Connection conn) {
        try {
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
115780
protected function commandStop(array $data, ConnectionInterface $conn)
    {
        if ($this->output->isVeryVerbose()) {
            $conn->on('close', function () {
                $this->output->writeln('Stop command requested');
            });
        }

        $conn->end(json_encode([]));

        $this->shutdown();
    }
646677
public void removeConnection(WebSocketConnection conn) {
        conns.remove(conn);
        for (IWebSocketDataListener listener : listeners) {
            listener.onWSDisconnect(conn);
        }
    }
272205
private void closeConnection( IConnection conn )
    {
        try
        {
            if( conn != null && conn.isOpen() )
                conn.close();
        }
        catch ( OdaException e )
        {
            // ignore
            e.printStackTrace();
        }
    }
950160
public function preDelete(ConnectionInterface $con = null)
    {
        parent::preDelete($con);

        if ($this->getIsDefault()) {
            return false;
        }

        $this->dispatchEvent(TheliaEvents::BEFORE_DELETEADDRESS, new AddressEvent($this));

        return true;
    }
611817
protected void destroyConnection(ThriftConnectionHandle<T> conn) {
		postDestroyConnection(conn);
		try {
			conn.internalClose();
		} catch (ThriftConnectionPoolException e) {
			logger.error("Error in attempting to close connection", e);
		}
	}
88127
function close(): \React\Promise\PromiseInterface {
        if($this->goingAway) {
            return $this->goingAway;
        }
        
        $deferred = new \React\Promise\Deferred();
        $this->goingAway = $deferred->promise();
        
        $closes = array();
        
        /** @var \Plasma\DriverInterface  $conn */
        foreach($this->connections->all() as $conn) {
            $closes[] = $conn->close();
            $this->connections->delete($conn);
        }
        
        /** @var \Plasma\DriverInterface  $conn */
        foreach($this->busyConnections->all() as $conn) {
            $closes[] = $conn->close();
            $this->busyConnections->delete($conn);
        }
        
        \React\Promise\all($closes)->then(array($deferred, 'resolve'), array($deferred, 'reject'));
        return $this->goingAway;
    }