You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Symfony 5.4迁移项目无法连接OrientDB的问题求助

Symfony 5.4迁移项目中ostico/orientdb连接OrientDB失败:socket_read()错误11

正在进行Symfony 5.4版本的项目迁移,使用ostico/orientdb组件连接OrientDB时触发500错误,具体报错信息如下:

"An error occurred","status":500,"detail":"socket_read(): unable to read from socketError 11 : Resource temporarily unavailable\n","class":"PhpOrient\\Exceptions\\SocketException","trace":[{"namespace":"","short_class":"","class":"","type":"","function":"","file":"/var/www/docker-symfony/vendor/ostico/phporient/src/PhpOrient/Protocols/Binary/OrientSocket.php","line":144.

已尝试以下修改,但问题仍未解决:

  1. 修改OrientSocket.php中的read函数为分段读取逻辑:
public function read($size) {
    $data = '';
    $bufferSize = 8192; // Vous pouvez ajuster cette taille

    while ($size > 0) {
        $readSize = min($bufferSize, $size);
        $_data = socket_read($this->_socket, $readSize, PHP_BINARY_READ);

        if ($_data === false || $_data === '') {
            throw new SocketException("socket_read(): unable to read from socket". $this->getErr());
        }

        $data .= $_data;
        $size -= strlen($_data);
    }

    return $data;
}
  1. 在_read_sync函数中启用日志输出:
public function _read_sync(){
    # type of response
    # decode body char with flag continue ( Header already read )
    $response_type = $this->_readChar();
    Constants::$LOGGING = true;

    $res = [];

    switch( $response_type ){
        case 'n':
            # get end Line \x00
            $this->_readChar();
            $res = array( null );
            break;
        case $response_type == 'r' || $response_type == 'w':
            $res = [ Record::fromConfig( $this->_readRecord() ) ];
            # get end Line \x00
            $this->_readChar();
            break;
        case 'a':
            $res = [ $this->_readString() ];
            # get end Line \x00
            $this->_readChar();
            break;
        case 'l':
            $list_len = $this->_readInt();

            for( $n = 0; $n < $list_len; $n++ ){
                $res[] = Record::fromConfig( $this->_readRecord() );
            }

            # async-result-type can be:
            # 0: no records remain to be fetched
            # 1: a record is returned as a result set
            # 2: a record is returned as pre-fetched to be loaded in client's
            #       cache only. It's not part of the result set but the client
            #       knows that it's available for later access
            $cached_results = $this->_read_prefetch_record();
            $res = array_merge( $res, $cached_results );
            # cache = cached_results['cached']
            break;
        default:
            # debug errors

            if( !Constants::$LOGGING ){
                throw new PhpOrientException( 'Unknown payload type ' . $response_type );
            }

            $msg = '';
            $m = $this->_transport->getSocket()->read(1);
            while( $m != '' ){
                $msg .= $m;
                $this->_transport->hexDump( $msg );
                $m = $this->_transport->getSocket()->read(1);
            }

            break;
    }

    return $res;
}

目前上述调整未解决问题,求技术支持定位并修复该socket读取错误。

内容的提问来源于stack exchange,提问作者sof

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 06:55:06