when to close a socket?
Terry Judd
tsj at unimelb.edu.au
Wed Feb 29 14:25:59 EST 2012
On 01/03/2012, at 12:19 AM, Dave Cragg wrote:
On 29 Feb 2012, at 09:49, Terry Judd wrote:
Hi guys - we have a reasonably complex Livecode app that makes lots of server requests - typically initiated by posting data to php routines on a secure (https) server. Generally things work well but occasionally things go awry and we start seeing slowdowns and odd errors (including the dreaded 'previous request not completed'), particularly if a number of requests are made in relatively quick succession.
Anyway, I was wondering whether there was any advantage to closing the open socket as soon as any data is returned rather than waiting for it close itself (there is a timeout interval of 5 seconds), thereby forcing any new request to open a new socket rather than using an 'old' open one?
If all the requests are to http urls, you could try adding a "Connection: close" header.
set the httpHeaders to "Connection: close"
This may not solve all the problems you are seeing, but it should cause the remote server to close the connection after replying and include a suitable header in its response. This will cause libUrl to close the socket and not attempt to use an already open one for subsequent requests. I've seen this solve problems where Livecode doesn't immediately recognize that a socket has been closed remotely and attempts to re-use it, resulting in an error.
Dave
Thanks Dave, that sounds promising. I'll give it a go.
Terry...
Dr Terry Judd
Senior Lecturer in Medical Education
Medical Eduction Unit
Faculty of Medicine, Dentistry & Health Sciences
The University of Melbourne
More information about the use-livecode
mailing list