webService crashes that cannot be intercepted

xojo web service
I created a webservice by copying what was written in the xojo examples. I obviously added more api …, in the handleurl event I process the path to understand the api to call and based on this I then process the body, expecting a different json model in the body based on the api called. In the handleurl event then I execute the control of the api (path) call, I interpret the body and create a json item, then I call the opening function db contained in a class module, I call the specific function for the desired api passing it the item json, finally the called function closes the connection to the db and in turn returns a json to the handeurl event which executes the response.write (with the json returned by the called function), and then executes the response.status = 200

everything works without problems only if the requests in the unit of time are few, if I create a query app with a cycle for the next from 0 to 1000 in which I make 1000 instant calls to the web app even if I run it in the debug environment, does anyone have things to suggest to me?

Hi Jury, if you send 1000 simultaneous requests to the WebService, how many are successfully processed, and what’s the response that the other requests receive? And, if you repeat this same test do the same number of requests succeed each time?

so, in reality I use a For Next loop from 0 to 1000 to do the test, so the requests are not simultaneous but sequential and always from the same ip. The webService correctly processes the first 10 (each request is in fact stored in a log table) after these 10 approximately, the service collapses without generating exceptions the webApp closes by itself, the annoying thing is that even in debugging the error is interceptible and therefore I do not understand where the problem arises. If, on the other hand, the requests are extended over time or translated over time, they do not seem to give problems.

Are those sockets?
You can’t have 1000 sockets open easily. And you may better use a timer with a few milliseconds between connections instead of a FOR loop.

Have you implemented App.UnhandledException and logged the stack & error?

2 Likes

ok we distinguish the two things, on the webService side I think there is a different approach compared to that of the use of the webSocket (sever), while on the client side each … single step of the for next instantiates a new class of the urlconnettion object, therefore the realities the limit shouldn’t exist and if it did it would be 65535 connections, I suppose

1 Like

No, I have to tell the truth no, I have not implemented this type of error handling, I have only used catches for each block or portion of code or function … err is runtimeexception …end try, today I try what you indicated ( that I didn’t know it existed)

thank you.

ok , the App.UnhandledException does not show errors but

I have inserted in the code of each api the opening at the end of the api the closing of the databases and the web app does not seem to crash when many requests arrive at the same time

Ok, so if you’re not getting Unhandled Exceptions, then we’d need to look at actual crash logs. I find this easiest if you start by just running the app from a terminal, cause the crash and see what gets printed to the terminal. If nothing shows there you’ll need to look at the system logs.

All that said, I suggest keeping an eye on system memory. There are a lot of reasons I see web apps just crash, but I’d say that 90% of the time has to do with running out of available RAM.