ssh2_exec执行在32kb数据后停止

I am using the php ssh2 methods to establish a connection to a server and transmit a string of ~39Kb. However, after 32Kb the transmission stops with an exception:

ErrorException: ssh2_exec(): Unable to request command execution on remote host in /var/www/xxx/xxxSSH.php:36

Is there an artificial limit on how many bytes can be transmitted in a session and if so, how can I change the limit?

UPDATE

Here's the method producing the error:

public function exec($cmd)
    {
    if (!($stream = ssh2_exec($this->connection, $cmd))) {
        throw new Exception('SSH command failed');
    }

    stream_set_blocking($stream, true);
    $data = "";
    while ($buf = fread($stream, 4096)) {
        $data .= $buf;
    }
    fclose($stream);
    return $data;
}

$cmd contains the string that seems to cause the trouble. What it does is call echo '$extremelyLongString' > /etc/someconfig.cfg

doumei1772
doumei1772 你试图增加你的内存限制,时间限制或流超时?
大约 2 年之前 回复
duanjue2560
duanjue2560 请编辑您的问题以显示您的php脚本中的相关代码,并指出产生错误的代码行。了解有关正在执行的远程命令的信息也很有帮助,特别是它是否产生任何输出和多少。
大约 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问