Reasons for hang on ASC_requestAssociation() ?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
walibi33
Posts: 9
Joined: Tue, 2017-11-21, 17:47

Reasons for hang on ASC_requestAssociation() ?

#1 Post by walibi33 »

Hi all,

I am experiencing a difficult issue that I can't really explain.
I work on a software solution (several executables) and two of them exchange DICOM data through DCMTK.
The emiter is a standalone executable and the receiver is a SYSTEM process launched by one daemon of our own.
The emission / reception process works perfectly fine the way these two entities are.

But for some business reasons we have to turn the receiver into a USER process.
So I made the changes to switch the process type, nothing to do with the DCMTK protocol at all.
And no change at all on the emiter side by the way.

The fact is that now the emiter hangs on the sending of DICOM data.
More precisely it enters the ASC_requestAssociation() function and never gets out...
Which I find really weird because either the request association fails, and then the execution exits right away from the function and resumes normaly, or the connection is established the data is then transmitted and the execution resumes too.

But the ASC_requestAssociation() is not supposed to hang like that. Because, as it is specified, it is asynchronous...

So basically I'm stuck here and I wanted to know if some of you have ever encountered similar hang with this function and what would be the reasons for that ?

Thanks in advance.

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: Reasons for hang on ASC_requestAssociation() ?

#2 Post by Jan Schlamelcher »

The one thing that comes to my mind would be that the port the receiver process is supposed to listen on is a priviliged port and cannot be listened on by user process. This would of course be operating system and configuration specific.

walibi33
Posts: 9
Joined: Tue, 2017-11-21, 17:47

Re: Reasons for hang on ASC_requestAssociation() ?

#3 Post by walibi33 »

Actually I took a look a bit closer of the primitives I use to create the receiver and I found some interesting info.
The OS our software solution works on is Windows:

- Without my changes the receiver is created with the ::OpenService() primitve that creates a Windows Service (in this case User Name process is SYSTEM).
- With my changes the receiver is created as a QProcess and launched with the QProcess::startDetached() primitive (in this case User Name of the process is $MYUSERNAME).

I looked up the QProcess documentation and I read that some Windows commands weren't supported with this way to start processes: http://doc.qt.io/qt-5/qprocess.html

I'm currently investigating on the limitations of QProcess, but it may be likely that DCMTK uses some Windows primitives that QProcess do not allow. Actually that won't be surprising to establish a TCP network connection...

So, in the end, I think the question I'm really trying to find some answers is: Does any limitation exist to use DCMTK through a process launched by QProcess ?

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Reasons for hang on ASC_requestAssociation() ?

#4 Post by Michael Onken »

Do you use storescp as the receiver? If so, can you try running it with --single-process?

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: Reasons for hang on ASC_requestAssociation() ?

#5 Post by Jan Schlamelcher »

You don't mean this section, right?
http://doc.qt.io/qt-5/qprocess.html#notes-for-windows-users wrote:Some Windows commands (for example, dir) are not provided by separate applications, but by the command interpreter itself. If you attempt to use QProcess to execute these commands directly, it won't work. One possible solution is to execute the command interpreter itself (cmd.exe on some Windows systems), and ask the interpreter to execute the desired command.
In case you did, this is about shell commands and not API functions, can't really be the reason for the issue unless you are trying to launch the DCMTK executable without using the full path to its binary... Btw: if you are building a QT application, why don't you simply include DCMTK on library level instead of spawning a process?

walibi33
Posts: 9
Joined: Tue, 2017-11-21, 17:47

Re: Reasons for hang on ASC_requestAssociation() ?

#6 Post by walibi33 »

@Michael Onken: We do not use the storescp application but a code of our own inspired from the storescp example (file dcmtk/dcmnet/apps/storescp.cc)
@Jan Schlamelcher: I meant this section indeed, but also this one:
On Windows, QProcess uses the Win32 API function CreateProcess to start child processes. While QProcess provides a comfortable way to start processes without worrying about platform details, it is in some cases desirable to fine-tune the parameters that are passed to CreateProcess. This is done by defining a CreateProcessArgumentModifier function and passing it to setCreateProcessArgumentsModifier.
Because I wonder whether some specific arguments need to be passed when process is created, before it is launched, to have it work properly in case of network communications...

walibi33
Posts: 9
Joined: Tue, 2017-11-21, 17:47

Re: Reasons for hang on ASC_requestAssociation() ?

#7 Post by walibi33 »

I pushed my investigation a bit further : I compiled dcmtk in debug with pdb files and followed execution into it to see where the code hangs.
Actually it hangs on a call to recv() function of the Winsock API, in the DcmTCPConnection::read() method.

And, again, when the receiver is launched as a SYSTEM process (Windows service) or as a USER process (but not through QProcess) it doesnt' hang.

walibi33
Posts: 9
Joined: Tue, 2017-11-21, 17:47

Re: Reasons for hang on ASC_requestAssociation() ?

#8 Post by walibi33 »

The Tcp port I used between the sender and the receiver was also used elsewhere.
I did change that. Now everything works just fine.
Problem solved.

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: Reasons for hang on ASC_requestAssociation() ?

#9 Post by Jan Schlamelcher »

So it was simply a coincendence that it worked unless launched via QProcess? That's a nice error, totally not difficult to identify :o.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Alexa [Bot], Google [Bot] and 1 guest