Under moderate load, we are seeing a large number of sockets left open in TIME_WAIT after service A has made a call to service B using standard JSONClient.
I need to profile what is occurring here, normally when I have seen this with WCF it is because a channel has not been closed correctly, although WCF channels are sustained. Even so, I think the sockets should be explicitly closed
Any general thoughts as to why we might be seeing this ?
Make sure you’re disposing any Stream or HttpWebResponse responses which need to manually disposed after you’ve finished using them. The service client disposes of all other responses.
Check that you’re not using any obsolete APIs where they can unknowingly return HttpWebResponse which need to be manually disposed, e.g:
[Obsolete("Use: using (client.Post<HttpWebResponse>(requestDto) { }")]
public virtual HttpWebResponse Post(object requestDto)
If you’re ignoring the response of a Service you’re calling, make sure it’s either marked with IReturnVoid or an IReturn<T> interface, otherwise the non-deprecated API for ignoring a response is for disposing it in a using statement, e.g:
using (client.Post<HttpWebResponse>(requestDto) { }