【发布时间】:2021-08-27 15:20:14
【问题描述】:
Twitter:OpenSSL SSL_read:对等方重置连接,errno 104
Twitter:操作在 5000 毫秒后超时,0 字节 收到了
这是我在尝试将视频文件分块上传到 Twitter 时(随机)遇到的两个错误。
1.5MB file = Most of the times uploads, sometimes gives error
10MB file = Always gives error (one of the above, randomly)
20MB file = Always gives error (one of the above, randomly)
我的代码与下面的代码非常相似:Upload Twitter video error (PHP). API response: Segments do not add up to provided total file size,我正在使用TwitterOAuth 库。
function append($mediaId, $fileUrl)
{
$segmentIndex = 0;
$handle = fopen($fileUrl, 'r');
while (!feof($handle))
{
$chunk = fread($handle, 4 * 1024 * 1024); // 4mb
$params = ['command' => 'APPEND', 'media_id' => $mediaId, 'media_data' => base64_encode($chunk), 'segment_index' => $segmentIndex];
$this->tw->uploadCustom('media/upload', $params);
$segmentIndex++;
}
}
我通过调试知道这个函数中抛出了错误。
"media" 上传的原始二进制文件内容。一定是
"media_data" base64 编码的媒体文件块。一定是
我尝试了这两个选项,但都没有成功。我错过了什么?为什么我不能上传更大的文件?
【问题讨论】: