Change request timeout SQL Server 2008 [closed]

1

I am sending a request within a procedure by SQL Server using WinHTTP.WinHTTPRequest.5.1, the problem is that the request is taking too long and this is giving a timeout error. I would like to increase the SQL Server timeout time.

I'm doing this in the procedure:

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?

    
asked by anonymous 25.01.2017 / 11:56

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 connect to the server;
  • 7000 - [dwSendTimeout] Time to submit the request;
  • 8000 - [dwReceiveTimeout] Time to receive the request response.

There it is:

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 found out by reading the WinHTTP documentation . for C ++.

    
25.01.2017 / 16:56