I have a web app (running on Xojo Cloud) that is REST server, and I have been testing the API with Postman and have had no problems getting responses back. I am starting to build out the desktop client app and have hit a wall. The desktop app is getting the following response from the web app on every request:
408 Request Timeout
Request Timeout
Server timeout waiting for the HTTP request from the client
I am using URLConnection.SendSync and as best as I can tell the requests are identical to what Postman is sending.
I tried it with Send also, and same result. The URL connection was originally in a thread, but I tried moving it to the window and no difference.
I have used URLConnection before to hit up 3rd-party APIs, like Cisco and Salesforce, and no problems. And Postman can get a proper response from the web app, but for whatever reason, it seems like URLConnection can’t properly communicate with the web app.
I think I’ll try writing a minimal web app and desktop client to see if I can replicate the problem there.
Wrote a couple of minimal test apps and found that URLConnection in a desktop app will timeout with Send or SendSync when using the GET method sent to a Xojo web app. Logging on the web app shows it never gets the request. However, any other method (POST, PATCH, DELETE, etc) works just fine.
I guess I can repurpose another method to function as GET since I am controlling both ends, but you would think GET would work.
I am on MacOS 10.15.7 and Xojo 2021r1, if that helps anyone figure this out.
The web framework doesn’t have any code path that returns a 408 error. You should be looking at the web server or proxy that’s in front of your app.
@Greg_O_Lone The web app was running on Xojo Cloud when I got the 408. I get a plain old timeout exception when running the web app locally.
But that isn’t really the problem it seems.
Why would a URLConnection GET timeout when sent to a web app, and other methods work fine? I can send a GET from Postman to the same web app and get a response.
time out after how much seconds?
have u used timeout argument in URLConnection.Send? https://documentation.xojo.com/api/networking/urlconnection.html#urlconnection-send
there are some notes about macOS
i think URLConnection does not need to be in a thread but you can sub class it
so you have your events and functionality there in your class.
and have a look what Postman send in http header at your request.
it could be that your data preparation if the request comes in is to slow.
means you have a long delay until data can send back.
if you send data rows as json do not send each field with key,value.
Xojo Cloud has Apache in front of the app. If it’s web 1, it’s simply in web server mode, but web 2 is a reverse proxy / load balancer configuration.
Could you show an example of a URLConnection GET request that is failing for you?
// Init a few things
PathComponents = Split(Request.Path, “/”)
// process request
If PathComponents.LastIndex = -1 Then
// no endpoint specified
handled = False
Else
// write response body
Select Case pathComponents(0).Lowercase
Case “rest”
Response.Status = 200
theJSON.Value(“status”) = “it works!”
Else
Response.Status = 404
theJSON.Value(“status”) = “resource not found”
End
Response.Write(theJSON.ToString)
handled = True
End
@MarkusR yes, correct. but only with GET. POST, PUT, PATCH, etc all work when sent from the desktop app. GET fails when the web app is running on Xojo Cloud AND when running locally in the debugger.
For the time being, I am using PUT in place of GET since I am not using PUT for anything else.
i made 2 minimal test apps and i get a response if me made a get request.
i tested with Xojo 2021r3.1 at windows 10 pc.
i started the server exe at port 9000.
Ran my client test app on Windows 10. Sent a GET to my web app running on Xojo Cloud and got a response. It looks like the issue is Mac-specific.
I have a work around so I am going to keep moving forward with the project. I might try upgrading Xojo to the current version to see if that fixes anything.