ofxThreadedImageLoader gives me "Host not found"

Hi everyone

I’m trying to load images asynchronously from the Tumblr API.

When I log these images synchronously, it works fine:

  
 for (int i = 0; i<nPosts-1;i++) {  
        posts[i]->photo.loadImage(posts[i]->photo_url);  
    }  
  

However, when I try to use the ofxThreadedImageLoader, it keeps giving me “Host Not Found” forever:

  
for (int i = 0; i<nPosts-1;i++) {  
        ofImage img = new OfImage();  
        images.push_back(img);  
        loader.loadFromURL(images.back(), posts[i]->photo_url);  
    }  
      
    loader.startThread(false, false);  

Any ideas why this might be? Thanks!

I’ve made some progress on this. In theory, loading photos works when I set up a urlResponse method:

  
void testApp::urlResponse(ofHttpResponse & response){  
	if(response.status==200 ){  
		img.loadImage(response.data);  
        posts[loadedNum]->photo  = img;  
		loading=false;  
	}else{  
		cout << response.status << " " << response.error << endl;  
		if(response.status!=-1) loading=false;  
	}  
    loadedNum++;  
}  

However, occasionally I still receive the message “Host not found.” This error never times out. I have read this-discussion on the issue but do not understand arturoc’s comment:

there’s actually a timeout, if not the connection will last forever, when the timeout is triggered if the response is asynchronous the status should be -1 indicating that the server is not available, you can catch that response in the newResponse event and remove the request from the queue using ofRemoveURLRequest(response.request.id) if you want or just let the class keep retrying till the connection is available again.

Can anyone give me more information on setting up this timeout?

I think Arturo means that:

if(response.status == -1) ofRemoveURLRequest(response.request.getID());

removes the request.