Configuring maxconnection in BizTalk

Sometimes when you are connecting to an API you get errors similar to the below

System.TimeoutException: The HTTP request to ‘https://XXX.my.salesforce.com/services/apexrest/xxxxxx’ has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout. —> System.Net.WebException: The request was aborted: The request was canceled.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
— End of inner exception stack trace —
Server stack trace:
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndRequest(IAsyncResult result)
Exception rethrown at [0]:
at System.Runtime.

Or

System.ServiceModel.CommunicationException: An error (The request was aborted: The request was canceled.) occurred while transmitting data over the HTTP channel. —> System.Net.WebException: The request was aborted: The request was canceled.
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStreamAsyncResult.CompleteGetRequestStream(IAsyncResult result)
— End of inner exception stack trace —
Server stack trace:
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndRequest(IAsyncResult result)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IM

This can be because using the default number of maximum connections of 2 and there too many messages queuing up to be processed in a timely manner. You can adjust this by adding the below to your BTSNTSvc.exe.config and BTSNTSvc64.exe.config, setting a default maximum connection and some specific connections for APIs where you either have a higher or lower limit.

<system.net>
       	<connectionManagement>
               	<add address="*" maxconnection="5"/>
                <add address="https://api.limitedconnections.com*" maxconnection="2"/>
                
                <add address="https://api.moreconnections.com*" maxconnection = "10"/>
       	</connectionManagement>
</system.net>

Further reading

HTTP Adapter Configuration and Tuning Parameters
More than 2 Concurrent connections not working in BizTalk 2013
BizTalk MaxConnections

Author: Coen (Colin) Dijkgraaf

A BizTalk developer at Datacom Systems Ltd, Auckland, New Zealand. You can follow me on Twitter, StackOverflow and WordPress

2 thoughts on “Configuring maxconnection in BizTalk”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.