dirkil2
asked on
InternetOpenUrl: how to increase timeout?
In my Delphi program I need to download a file. Since when the request arrives it takes some time for the server to compile the data to download it could happen that the client has to wait for some time. Unfortunately, my client doesn't wait long enough and the call to InternetOpenUrl returns error code 12002.
Therefore my question: how can I increase the time allowed to wait for the InternetOpenUrl call to return?
See attached code for details.
Regards,
Dirk.
Therefore my question: how can I increase the time allowed to wait for the InternetOpenUrl call to return?
See attached code for details.
Regards,
Dirk.
hSession := InternetOpen('MyApp', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
if not Assigned(hSession) then Exit;
try
hService := InternetOpenUrl(hSession, PChar(aUrl), nil, 0, 0, 0);
if not Assigned(hService) then
begin
FErrorText := SysErrorMessage(GetLastError);
Exit;
end;
ASKER
If I am not mistaken this is exactly the same as my code. The call to InternetOpenUrl times out and then your code exits as mine does.
Maybe this code can help you for setting timeout:
http://translate.google.com.br/translate?hl=pt-BR&sl=zh-CN&tl=en&u=http%3A%2F%2Fwww.gz183.com.cn%2FInfo%2F114%2Finfo22897_1.htm
http://translate.google.com.br/translate?hl=pt-BR&sl=zh-CN&tl=en&u=http%3A%2F%2Fwww.gz183.com.cn%2FInfo%2F114%2Finfo22897_1.htm
ASKER
See attachment for information which timeouts I tried. But unfortunately I am always getting error 317 back.
When I try and enter the same request into Internet Explorer it downloads the file.
I am still hoping that someone has an idea how I can avoid this timeout.
When I try and enter the same request into Internet Explorer it downloads the file.
I am still hoping that someone has an idea how I can avoid this timeout.
dwTimeOut : DWORD;
begin
dwTimeOut := 1800000;
InternetSetOption(hService, INTERNET_OPTION_CONNECT_TIMEOUT, @dwTimeOut, SizeOf(dwTimeOut));
InternetSetOption(hService, INTERNET_OPTION_SEND_TIMEOUT, @dwTimeOut, SizeOf(dwTimeOut));
InternetSetOption(hService, INTERNET_OPTION_RECEIVE_TIMEOUT, @dwTimeOut, SizeOf(dwTimeOut));
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window