フィルターのクリア

how to resolve Recv failure: connection was reset error

199 ビュー (過去 30 日間)
Yujin
Yujin 2023 年 12 月 20 日
コメント済み: Yujin 2024 年 1 月 2 日
Hi, I am trying to collect some images from google api, and I get recv errors when trying to save the file to a local folder,
>> websave('test.jpg', 'http://atlas-content-cdn.pixelsquid.com/stock-images/blue-yellow-basketball-ball-J3JE6aD-600.jpg')
Error using websave
Error connecting to http://atlas-content-cdn.pixelsquid.com/stock-images/blue-yellow-basketball-ball-J3JE6aD-600.jpg: Recv
failure: Connection was reset
I can access the url via chrome broswer, but not in matlab
Any idea what cause it, and how to fix it

採用された回答

Shivang
Shivang 2023 年 12 月 27 日
Hi Yujin,
From what I understand, you're running into an error while trying to download an image using 'websave'.
I am not able to reproduce this issue, but the following steps might help in troubleshooting:
import matlab.net.http.*
url = 'http://atlas-content-cdn.pixelsquid.com/stock-images/blue-yellow-basketball-ball-J3JE6aD-600.jpg';
filename = 'test.jpg';
request = RequestMessage('GET');
response = request.send(url);
if response.StatusCode == 200
imageData = response.Body.Data;
imwrite(imageData,filename);
end
Hope this helps!
  1 件のコメント
Yujin
Yujin 2024 年 1 月 2 日
I have added 'timeout' option to websave, it helped some cases, but other cases may be caused by the server end, so I have to drop any attempt with recv error.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCall Web Services from MATLAB Using HTTP についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by