When an application initiates an outbound connection to a database or a remote service, it uses the TCP connection from a range of allowed TCP connections on the machine. In some scenarios, the number of available outbound ports might get exhausted and when the applications tries to initiate a new connection request, it might fail with this error:
: An attempt was made to access a socket in a way forbidden by its access permissions.
COMMON REASONS THAT CAUSE THIS ERROR:
Using client libraries which are not implemented to re-use TCP connections.
Application code or the client library is leaking TCP socket handles.
Burst load of requests opening too many TCP socket connections at once.
In case of higher level protocol like
this is encountered if the
option is not leveraged.
For a .NET application,the below code-snippet will log the active outbound connections and details about the external service to which it is connecting. This will not log database related connections as they do not use
. You can create a page PrintConnectionsSummary.aspx under the site and place it under
folder. When the application encounters the socket exceptions, the users can browse to the page
to see the connection count to the remote services.