Cannot set the Local Port for an Association for C-MOVE

77 views
Skip to first unread message

Tamás Sipos

unread,
May 17, 2018, 5:55:48 AM5/17/18
to dcm4che
I'd like to retrieve a study from DCM4CHEE from a JAVA application (AE Title: MYJAVAAPP) using C-MOVE.
Both DCM4CHEE and MYJAVAAPP are running on the same computer.

I have added MYJAVAAPP to the list of AEs in DCM4CHEE:

Title: MYJAVAAPP     Host: localhost     Port: 11113

When building up an association in the JAVA application for a C-MOVE, as far as I understand, I have to set the local port of the connection to match the one configured in DCM4CHEE for MYJAVAAPP. I'm doing it this way:

ApplicationEntity locAE = new ApplicationEntity();
locAE
.setAETitle("MYJAVAAPP");
ApplicationEntity remAE = new ApplicationEntity();
remAE
.setAETitle("DCM4CHEE");

Connection localConn = new Connection();
localConn
.setHostname("localhost");
localConn
.setPort(11113); // THIS IS THAT LINE, BUT IT HAS NO EFFECT :( -SEE THE LOGS BELOW
localConn
.setProtocol(Connection.Protocol.DICOM);
locAE
.addConnection(localConn);

// Defining the remote part of the connection...
Connection remoteConn = new Connection();
remoteConn
.setHostname("localhost");
remoteConn
.setPort(11112);
remoteConn
.setProtocol(Connection.Protocol.DICOM);
remAE
.addConnection(remoteConn);

Device device = new Device("device");
device
.addConnection(localConn);
device
.addApplicationEntity(locAE);
ExecutorService exec = Executors.newSingleThreadExecutor();
device
.setExecutor(exec);

AAssociateRQ assocReq = new AAssociateRQ();
assocReq
.setCalledAET(remAE.getAETitle());
assocReq
.setCallingAET(locAE.getAETitle());
assocReq
.setApplicationContext("1.2.840.10008.3.1.1.1");
assocReq
.setImplClassUID("1.2.40.0.13.1.3");
assocReq
.setImplVersionName("dcm4che-5.12.0");
assocReq
.addPresentationContext(new PresentationContext(
 
1, "1.2.840.10008.5.1.4.1.2.2.2", "1.2.840.10008.1.2"));

Association assoc = locAE.connect(localConn, remoteConn, assocReq);

...

And this is the log produced after running the above code:

2018-05-17 11:07:14,849 INFO  -> (TCPServer-1) [org.dcm4cheri.server.ServerImpl] handle - Socket[addr=/127.0.0.1,port=50251,localport=11112]
2018-05-17 11:07:14,849 INFO  -> (TCPServer-1) [org.dcm4cheri.net.FsmImpl] Socket[addr=/127.0.0.1,port=50251,localport=11112]
2018-05-17 11:07:14,852 INFO  MYJAVAAPP->DCM4CHEE (TCPServer-1) [org.dcm4cheri.net.FsmImpl] received AAssociateRQ
 appCtxName: 1.2.840.10008.3.1.1.1/
DICOM Application Context Name
 implClass
: 1.2.40.0.13.1.3
 implVersion
: dcm4che-5.12.0
 calledAET
: DCM4CHEE
 callingAET
: MYJAVAAPP
 maxPDULen
: 16378
 asyncOpsWindow
:
 pc
-1: as=1.2.840.10008.5.1.4.1.2.2.2/Study Root Query/Retrieve Information Model - MOVE
 ts
=1.2.840.10008.1.2/Implicit VR Little Endian
2018-05-17 11:07:14,853 INFO  MYJAVAAPP->DCM4CHEE (TCPServer-1) [org.dcm4cheri.net.FsmImpl] sending AAssociateAC
 appCtxName
: 1.2.840.10008.3.1.1.1/DICOM Application Context Name
 implClass
: 1.2.40.0.13.1.1.1
 implVersion
: dcm4che-1.4.34
 calledAET
: DCM4CHEE
 callingAET
: MYJAVAAPP
 maxPDULen
: 16352
 asyncOpsWindow
:
 pc
-1: 0 - acceptance
 ts
=1.2.840.10008.1.2/Implicit VR Little Endian
2018-05-17 11:07:14,856 INFO  MYJAVAAPP->DCM4CHEE (TCPServer-1) [org.dcm4cheri.net.FsmImpl] received A-RELEASE-RQ
2018-05-17 11:07:14,856 INFO  MYJAVAAPP->DCM4CHEE (TCPServer-1) [org.dcm4cheri.net.FsmImpl] sending A-RELEASE-RP
2018-05-17 11:07:14,950 INFO  MYJAVAAPP->DCM4CHEE (TCPServer-1) [org.dcm4cheri.net.FsmImpl] closing connection - Socket[addr=/127.0.0.1,port=50251,localport=11112]
2018-05-17 11:07:14,950 INFO  -> (TCPServer-1) [org.dcm4cheri.server.ServerImpl] finished - Socket[addr=/127.0.0.1,port=50251,localport=11112]

As you can see, dcm4che in the JAVA application picks a random port (this time 50251) for the socket and not the one I have defined using localConn.setPort(11113). After that, a C-MOVE of course fails, because DCM4CHEE tries to contact back the JAVA application on port 11113, which results in a

java.net.ConnectException: Connection refused

as there is no device listening on that port. Can someone help me out with this?

P.S: I checked the library Nicolas Roduit recommended to me in a previous topic of mine regarding this same issue. I looks great and I would gladly give it a try, but right now I'm unfortunately not allowed to modify the dependencies of the project I'm working on, so I have to stick with dcm4che only.

Nicolas Roduit

unread,
May 18, 2018, 1:48:30 AM5/18/18
to dcm4che
If you want to rebuild the C-Move process you need to fully understand the C-Move operation which is not simple. That's why I will recommend using a library. It is difficult to answer with partial information. It seems your want to build a C-Move like C-Get. In your demonstration, we don't see a listener with the port 11113. The port of the association is something different.

Tamás Sipos

unread,
May 21, 2018, 5:20:46 PM5/21/18
to dcm4che
Thanks, now I see. I need some association listener in my java app that can accept the incoming c-store request from dcm4chee when it responds to my c-move. Something to implement as a runnable and start as a thread. In dcm4che's source code I could only find an AssociationListener interface, but that's not much of a help yet. Could you maybe link some relevant piece of code to check out that basically shows how to implement an association listener with dcm4che? Anything to put me on the right path. If not, maybe I should stick with c-get.
Reply all
Reply to author
Forward
0 new messages