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.