HandleSpecialURL Timeout

Hi everyone. In reference to this post: https://forum.xojo.com/29885-can-handlespecialurl-timeout/ - I’m experiencing the same thing. I see the poster solved it with threads.

I tried moving my HandleSpecialURL code to a thread, but it still is timing out other requests. Can anyone share how you would set up your thread code and how you are waiting for the thread to end and then returning back the result? I’m doing something like this:

In the HandleSpecialURL event:

Dim t As New HandleSpecialURLThread t.Request = Request t.Run While t.State <> t.NotRunning DoEvents Wend

And inside the thread it will do a Request.Print to send some data back to the request.

No matter what I try, it still times out any other attempts to post a request to special url if a request is already in progress. I also tried replacing DoEvents with YieldToNextThread to no avail. I know I must be missing something obvious here…

Thanks!

There’s no sense in using a thread if you’re going to follow it with a while loop like that.

The response isn’t actually sent to the client until the event finishes.

Thanks. That makes sense. What would be the right way to wait for the thread to finish and return the response?

Are you using this as an API?

Yes

In my experience when you do a long operation, the correct answer is to set the http response code to 202 with a response body that indicates where the client should go to find out if the request is complete. Then you use a thread to do the processing. The client polls the given url until it gets a full response.

[quote]202 Accepted
The request has been accepted for processing, but the processing has not been completed. The request might or might not be eventually acted upon, and may be disallowed when processing occurs.[/quote]

Thanks Greg. Actually I take all this back, HandleSpecialURL works just fine (even without the thread method). Of course it was some totally unrelated issue (hate when that happens! But I think every programmer knows exactly what I’m talking about :)) that was causing the app to crash in certain circumstances (I was testing it on Xojo Cloud), thus causing the timeout.

Glad you found the issue!