

narag
Members-
Content Count
10 -
Joined
-
Last visited
Community Reputation
0 Neutral-
How to know when TIdHTTPServer threads are done
narag replied to narag's topic in Network, Cloud and Web
Thank you, that seems to cover all the needs -
How to know when TIdHTTPServer threads are done
narag replied to narag's topic in Network, Cloud and Web
I write the new .exe with updated code to another location in the the disk, I execute it, listening in a new port and I tell the load balancer to send all new requests to that port. Then I do whatever I need to do ("TIdHTTPServer.Active := False" or TIdHTTPServer.StopListening" or custom code if it's not enough) to tell the old instace to stop accepting connections and then process the standing ones before shutdown. In other words: it's the way to update a working service without clients even noticing it. The updates would be for non-critical errors or enhancements, so it makes sense to keep the old code working until it can be replaced. I had understood that "Active := False" would call StopListening so the pending transactions would complete before the instruction following "Active := False" is executed đŸ¤” Should I call StopListening on its own instead of "Active := False" instead? No, it's a REST web service, only used by other programs, not browsers. I'll make sure that KeepAlives is disabled, thank you for the heads up. -
How to know when TIdHTTPServer threads are done
narag replied to narag's topic in Network, Cloud and Web
Updating the server. The traffic is diverted to a new instance with updated code, then the "old" server is shut down, but if there are clients already connected to the instance that is shutting down, the transactions must be completed, not interrupted. There are a few endpoints that carry lengthy database operations, not so long as to cause timeouts, but long enough, half a minute sometimes, to give them a little leeway. Of course I didn't mean migrating the transactions to another process, that would be... an interesting problem So Active is safe... that's great, so I can clean the connection pool just sequentially after Active := False. Thank you so much! -
How to know when TIdHTTPServer threads are done
narag replied to narag's topic in Network, Cloud and Web
Wait, so will Active := False shut up the current connections? I've followed the code and there's a closesocket in DoTerminateContext. That's not very nice to the clients. My intention is to hot swap servers gracefully, without causing connections errors. Even StopListening seems to close threads' sockets. If there's no "soft" way to stop accepting new connections, it seems I need to write that active thread list. -
How to know when TIdHTTPServer threads are done
narag replied to narag's topic in Network, Cloud and Web
Thank you, that will do. -
Hi, I'm using a TIdHTTPServer component and I would like to know, after its Active property is set to False, when all the current threads have finished serving. I could hold a count of active threads, but maybe instead of introducing just another synchronization mechanism, there's some out of the box property or event that I could use. TIA, Nico
-
Remy, thank you for your help. I can't post the real file because it contains confidential data. Any example would be made up anyway. You were right there were two different problems. The AV was caused by my bad understanding of the load methods. The encoding errors went away when directly feeding the SOAP output to the parser input. It seems that using a string in the middle was triggering automatic conversions that the parser didn't like.
-
Most new interfaces use REST and JSON, that seem to be easier to get right. Still I'm not sure where to put the blame exactly. Maybe it's just me đŸ™‚
-
And still, that's the error that I get: Project Xml2Json.exe raised exception class EDOMParseError with message 'Se encontrĂ³ un carĂ¡cter no vĂ¡lido en el contenido del texto. Line: 10 <Agent>SOMEMF Ga'. And yes, that's the position where the first non-ANSI char is. I started with the SOAP interface directly feeding the XML parser. That caused AV. Debugging step by step doesn't help very much, because most of the time I fall into System unit assembler that (I guess) dispatches interfaces calls. So I write the XML to file and then read it to make sure the encoding is right, but it still complains. Is there another library that I can use? Thank you!
-
I've been assigned the task of connecting to a SOAP web service and reading a list of offices that will be sent to me in XML. I've worked with SOAP and Delphi before, but not both at the same time in the last decade, so I've been going through what seems to be the usual procedure: creating an interface unit with the IDE wizard (Delphi 11) from the WSDL URL, using the properties that interface gives me to login (it works) and passing the XML to TXMLDocument. This is where the joy ends. The text I get doesn't have an XML header, it contains spaces inside the values and non-ANSI characters. I've tried to follow the execution, but it goes into sections of assembler and external calls, it seems that TXMLDocument is a wrapper around a Windows library. The final error is usually AV when I ask for "ChildNodes" from the root. From this description, can you think of any steps where I might be screwing up? Is there any component or library that can replace the ones I use? I also tried a unit that comes with SuperObject (I have to convert the list to JSON later), but it also gets stuck with the received XML. If it were just to get the list of offices, I would even consider making an ad hoc parser, but I'm afraid I'll soon have to interact a lot more with that API. Thanks in advance!