Change timeout SQL Server 2008 request

Asked

Viewed 387 times

1

I am sending a request inside a database by SQL Server using Winhttp.WinHTTPRequest. 5.1, the problem is that the request is taking too long and is giving timeout error. I would like to increase the timeout time of SQL Server.

I’m doing it like this at the trial:

exec sp_OACreate 'WinHTTP.WinHTTPRequest.5.1', @Object out;
exec sp_OAMethod @Object, 'open', NULL, 'POST', @url, 'false';
exec sp_OAMethod @Object, 'setRequestHeader', null, 'Content-Type', 'application/json';
exec sp_OAMethod @Object, 'send', null, @Body;
exec sp_OAMethod @Object, 'status', @status output;
exec sp_OAMethod @Object, 'responseText', @ResponseText output;
exec sp_OADestroy @Object;

Does anyone know how to set the timeout?

  • 1

    Maybe what you should do is revise your query!

  • The server is not mine, I have no way to optimize the processing.

  • But the problem does not seem to be with sqlserver but rather with setting up Winhttp.Winhttprequest, or am I mistaken? So much so that I believe you are not sending by sqlserver but calling a page that uses sql-server in the back end.

  • No, the request is made by a precedent in SQL Server.

1 answer

1


I was able to increase the timeout with the command:

exec sp_OAMethod @Object, 'setTimeouts', null, '5000', '6000', '7000', '8000';

Where:

  • 5000 - [dwResolveTimeout] Time to resolve the server url in DNS;
  • 6000 - [dwConnectTimeout] Time to establish connection to the server;
  • 7000 - [dwSendTimeout] Time to send the request;
  • 8000 - [dwReceiveTimeout] Time to receive the request reply.

There he was:

exec sp_OACreate 'WinHTTP.WinHTTPRequest.5.1', @Object out;
exec sp_OAMethod @Object, 'open', NULL, 'POST', @url, 'false';
exec sp_OAMethod @Object, 'setRequestHeader', null, 'Content-Type', 'application/json';
exec sp_OAMethod @Object, 'setTimeouts', null, '5000', '60000', @vTimeout, @vTimeout;
exec sp_OAMethod @Object, 'send', null, @Body;
exec sp_OAMethod @Object, 'status', @status output;
exec sp_OAMethod @Object, 'responseText', @ResponseText output;
exec sp_OADestroy @Object;

I discovered by reading the documentation of Winhttp for C++.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.