How to increase the read_timeout for a request?


#1

I have created a request like this:
request = Sketchup::Http::Request.new(OPTMIZE_URL, Sketchup::Http::POST)

How could I increase the read_timeout property ? Since my request take more than 60 secs to complete.


#2

Is Sketchup::Http::STATUS_FAILED returned in the #start block after 60 seconds ?

(Ping @thomthom )


#3

You mean it takes longer than 60 secs for the server to respond?
Because, if there is a response, and the actual download lasts for longer - then there should be no timeout.

I’ll assume you are referring to timeouts when server doesn’t respond. I asked another team member who’s more familiar with Chromium and he said there is no timeout on our end. And from what he could tell, there was no support for this in Chromium either, citing these references:


https://magpcss.org/ceforum/viewtopic.php?f=6&t=13080&p=26290&hilit=request+timeout#p28392


#4

For long-lasting server processes, it’s better to make them asynchronous instead of assuming/requiring that the client is implemented in a certain way.
Make the server start a process/thread and return immediately a generated URL where the client will be able to fetch the result (like from a simple storage server e.g. Redis).
Make the client poll this URL until the result is there, and then download it.


#5

Thanks guys. Need to change the logic.


#6

Server is responding after 5 mins but request is not responding to the response.
It seems request is closing and not responding to the response.


#7

You need to reference the request using a persistent Ruby reference that will not go out of scope and get garbage collected by Ruby.

This usually means a instance variable.