Strange situation: different velocity between fo-dicom PKG and Code

95 views
Skip to first unread message

RTDicomExplorer

unread,
Mar 30, 2022, 7:11:08 AM3/30/22
to Fellow Oak DICOM
Hi Gents,
I am faced with a situation that I cannot explain. Running a simple ECHO test with dicomserver.co.uk but with a wrong port, I get an exception response with very different times: Using the test in fo-dicom code it takes 21 sec.
 [Fact]
        public async Task OnCEchoRequestAsync_ShouldRespond()
        {
            var port = 11115; // Ports.GetNext()+1;

          //  using (DicomServerFactory.Create<AsyncDicomCEchoProvider>(port, logger: _logger.IncludePrefix("DicomServer")))
            {
                var client = DicomClientFactory.Create("www.dicomserver.co.uk", port, false, "SCU", "ANY-SCP");
                client.Logger = _logger.IncludePrefix(typeof(DicomClient).Name);
                client.ClientOptions.AssociationRequestTimeoutInMs = (int) TimeSpan.FromMinutes(5).TotalMilliseconds;

                DicomCEchoResponse response = null;
                DicomRequest.OnTimeoutEventArgs timeout = null;
                var request = new DicomCEchoRequest
                {
                    OnResponseReceived = (req, res) => response = res,
                    OnTimeout = (sender, args) => timeout = args
                };

                var timer = new Stopwatch();
                timer.Start();
                try
                {
                    await client.AddRequestAsync(request).ConfigureAwait(false);
                    await client.SendAsync().ConfigureAwait(false);

                }
                catch(Exception ex)
                {
                    timer.Stop();
                    TimeSpan timeTaken = timer.Elapsed;
                    string foo = "Time taken: " + timeTaken.ToString(@"m\:ss\.fff");
                    Console.WriteLine($"{foo} : {ex.Message}");
                }

                Assert.NotNull(response);
                Assert.Equal(DicomStatus.Success, response.Status);
                Assert.Null(timeout);
            }
        }

But when i use the same test in an example where is referenced the fo-dicom pkg, it takes 42 sec.  In a Linux Machine it even takes 2 min. 

Can anyone please chek it ? 
Thanks...
Michele

Reinhard Gruber

unread,
Apr 16, 2022, 11:43:45 AM4/16/22
to Fellow Oak DICOM
fo-dicom opens an tcpconnection with 

            _tcpClient = new TcpClient { NoDelay = noDelay };
            _tcpClient.ConnectAsync(host, port).Wait();
            Stream stream = _tcpClient.GetStream();

the AssociationRequestTimeoutInMs plays a role, when sending the associationrequest messages on this created networkstream. 
So the different timeouts can only be explained by different defaults on different machines/settings.
Reply all
Reply to author
Forward
0 new messages