- Ensure MATLAB's "Web Preferences" are set correctly. Refer to this link: https://www.mathworks.com/help/matlab/matlab_env/web-preferences.html
- Try setting a higher timeout by adding a 'weboptions' object in the arguments of 'websave'. Refer to this link: https://www.mathworks.com/help/matlab/ref/weboptions.html
- You could also try using MATLAB's HTTP interface:
how to resolve Recv failure: connection was reset error
조회 수: 115 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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!
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Web Services에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!