Exception thrown whilst searching for studies on Dicom server, "The socket is no connected"

34 views
Skip to first unread message

James Allsopp

unread,
Apr 13, 2018, 11:41:28 AM4/13/18
to Fellow Oak DICOM
Hello,
I've just had a intermittent problem running a search of a dicom server for studies asssociated with a patient. The code that caused the error is: 
            var lastQueryResponse = new List<Study>();
            lastQueryResponse.Clear();
            DicomCFindRequest request = DicomCFindRequest.CreateStudyQuery(patientId: patientId);
            request.OnResponseReceived = delegate (DicomCFindRequest req, DicomCFindResponse response)
            {
                if (response.HasDataset)
                {
                    lastQueryResponse.Add(Study.CreateStudyFromCFindResponse(response));
                }
            };

            DicomClient client = new DicomClient();
            client.AddRequest(request);
            var pacs = MvcApplication.GlobalSettings.SourceDicom;
            client.Send(pacs.Ip, pacs.Port, false, MvcApplication.GlobalSettings.ClientAE, pacs.Ae);
            return lastQueryResponse;

The stack trace is this:
System.Net.Sockets.SocketException (0x80004005): The socket is not connected
  at System.Net.Sockets.TcpClient..ctor (System.String hostname, System.Int32 port) [0x0006d] in <a67b90c5acf54694896b770f716b945d>:0
  at Dicom.Network.DesktopNetworkStream..ctor (System.String host, System.Int32 port, System.Boolean useTls, System.Boolean noDelay, System.Boolean ignoreSslPolicyErrors) [0x000
22] in <37262de083e745ab909a0e5412c10b69>:0
  at Dicom.Network.DesktopNetworkManager.CreateNetworkStreamImpl (System.String host, System.Int32 port, System.Boolean useTls, System.Boolean noDelay, System.Boolean ignoreSslP
olicyErrors) [0x00000] in <37262de083e745ab909a0e5412c10b69>:0
  at Dicom.Network.NetworkManager.CreateNetworkStream (System.String host, System.Int32 port, System.Boolean useTls, System.Boolean noDelay, System.Boolean ignoreSslPolicyErrors
) [0x00000] in <37262de083e745ab909a0e5412c10b69>:0
  at Dicom.Network.DicomClient.Send (System.String host, System.Int32 port, System.Boolean useTls, System.String callingAe, System.String calledAe) [0x0008e] in <37262de083e745a
b909a0e5412c10b69>:0
  
This seemed to happen on a patient with a large number of studies, so we're wondering if this is a time out? If so, how would we go about fixing this?

Thanks
James

reini....@aon.at

unread,
Apr 16, 2018, 2:24:37 PM4/16/18
to Fellow Oak DICOM
I took a look at the stack trace. the exception happens when the client tries to create a tcp connection to the server. at that moment not a single command has been sent to the server, so it cannot depend on the number of studies.
The client is just not able to connect to the server. Maybe the server is bussy at this moment or the number of parallell associations is limited there and there are too many associations open on the server.

This System.Net.Sockets.SocketException (0x80004005) comes from the network layer and in my opinion should not be catched by fo-dicom. If you catch it I would recommend to wait a while (a second or so) and then retry the send command until you reach a max retry count.
Reply all
Reply to author
Forward
0 new messages