Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Time Out duration for requested association for C-Echo / C-Store #1752

Open
mohantyytasre opened this issue Mar 11, 2024 · 4 comments
Open
Labels

Comments

@mohantyytasre
Copy link

mohantyytasre commented Mar 11, 2024

Expected behavior

To allow the client to set the association requested time duration if association fails and to abort the association and client.

I am using C-Echo/C-store SCP program codes to test the Server with particular AET, IP address and Port #.
After providing wrong AET/IP address / Port # for server association request must get terminated after Association Request Timed Outset duration .

Actual behavior

I am not able to set the association requested time duration.
Please help me with this for implementation as I am still learning c# and so not able to get the syntax

Steps to reproduce the behavior

DicomCEchoRequest CEchoRequest = new DicomCEchoRequest();

        _echoServerHost = store_ServerHost;
        _echoServerPort = store_ServerPort;
        _echoServerAET = called_aet;
        _echoClientAET = calling_aet;

        var client = CreateDicomClient(store_ServerHost, store_ServerPort, calling_aet, called_aet);
        
        client.AssociationRequestTimedOut += (sender, e) =>
        {
            var t = e.TimeoutInMs;
           UpdateServerStatus("Association accepted by SCP");
        };

fo-dicom version and OS/platform

fo-dicom : 5.1.1
OS : Windows

@ChrisNewell-Inari
Copy link

In the API Documentation, the DicomClient constructonr lets you set the AssociationRequestTimeoutInMs via the DicomClientOptions hope this helps!

@mohantyytasre
Copy link
Author

mohantyytasre commented Mar 14, 2024

Thanks for reply....
I did used it and found that default Association Request Time Out duration is 5000 ms. I have added the Eventhandler with client as

        client.AssociationRequestTimedOut += (sender, e) =>
        {
            UpdateServerStatus($"Association requested for server time out: "+e.String());
        };

But even after no response from server after 5 sec. this event handler is not getting accessed by program. But also the system.exception error is getting logged as Exception thrown: 'System.Net.Sockets.SocketException' in System.dll.
So is it that where it is not allowing and exiting the current thread.
Also is there a way to cancel a request sent by client because in some discussions I have read that C-Cancel is not supported by fo-dicom.

@ChrisNewell-Inari
Copy link

Maybe A-Abort?

@gofal
Copy link
Contributor

gofal commented Mar 24, 2024

Take a look at this class: Tests/FO-DICOM.Tests/Network/Client/DicomClientTimeoutTests.cs
This are the unit tests about timeouts in clients. There you also find a method that tests the AssociationRequestTimeout:

public async Task AssociationRequestTimeOutExceptionShouldThrowAfterMaxRetry()

Basically, you have to wrap your await client.SendAsync() in a try-catch-block and catch the DicomAssociationRequestTimeOutException instead of only adding a handler to the event. You should catch all exceptions, also the SocketException.

You also can cancel requests. You can pass a CancellationToken as parameter to client.SendAsync(cancellationToken).

@gofal gofal added the question label Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants