Terminal Server and Printer not activated -30

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
chopsdogg
Posts: 16
Joined: Mon Dec 27 2004

Terminal Server and Printer not activated -30

Post by chopsdogg »

I was having problems in 3.01a with getting the "Activation Error Printer not activated, error code -30" error as related to the 20 second timeout. I have that all taken care of now using the EnabledPre event to activate and enable the printer just-in-time. This is working fine for our users when using a fat client. However, in terminal server they will be able to print a few times to the PDF Converter, but eventually users will start seeing the "Activation Error Printer not activated, error code -30" error again.

I am suspecting this has to do with multiple users accessing the PDF Coverter at the same time, etc. Are there any guidelines on how to implement the PDF Converter in a terminal server environment or multiple users accesing it on the same machine? I have looked through the PDF Converter documentation as well as the CDI documentation and not found anything, but I seem to remember reading something before.

Have there been any other reports of this issue in terminal server? Any suggestions? This "Activation Error Printer not activated, error code -30" issue has really been killing us since upgrading to the 3.0x version of the PDF Converter and have had to release several patches to our software.
chopsdogg
Posts: 16
Joined: Mon Dec 27 2004

Post by chopsdogg »

I found the technical note on "Multitasking the AMYUNI
printer drivers" at www.amyuni.com/downloads/tn01.zip. The documentation states this is with regards to web server applications or services. Would this also apply to multiple users running on a terminal server and the PDF Converter permanently installed as a printer on the terminal server? This seems a little different and is talking about the same process interacting with a single PDF Converter object.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

If you are in a multithreading environment, or multiple users can access the printer at the same time, you will need to use the Locking mechanism of CDIntf.

For more information please seach for the function 'Lock' in the Developers' manual "Common Driver Interface.pdf".

Hope this helps.
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html

Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
chopsdogg
Posts: 16
Joined: Mon Dec 27 2004

Post by chopsdogg »

FYI we are using the ActiveX interface. I have implemented locking using the GLock() and GUnlock() functions. However, I still see the problem.

In process A I have code so that calls GLock(), sets all the prosperities (options, file name, folder name, etc), a job is sent to the PDF Converter, then I have a modal dialog box pop up that will "freeze" the process just before calling GUnlock().

Now on my second process B on a separate terminal server session I call the same code and the process is halted when it tries to call GLock() itself.

If I go back to process A and now close my modal dialog box, GUnlock() is called and I immediately get the -30 error. Sometimes the -30 error pops up on process B sometimes it pops up on process A.

Two questions.

1. Why am I still seeing the -30 error in this situation?

2. What is the difference between GLock() and Lock(). They appear to be the same to me from the documentation, except that Lock() requires the name of the job as it appears in the Windows print queue. For us the name of the job in the queue is way too hard to know ahead of time when calling the Lock(), so I used the GLock() method.
chopsdogg
Posts: 16
Joined: Mon Dec 27 2004

Post by chopsdogg »

One other thought. We are permanently installing the PDF Converter. In our application we are creating up an instance of the ActiveX control and calling DriverInit for each instance of the .exe. Is it okay to call DriverInit multiple times on the same terminal server, but under different sessions? I read some documentation somewhere that we should only be calling this once.
chopsdogg
Posts: 16
Joined: Mon Dec 27 2004

Post by chopsdogg »

I have some more information. I have noticed on the terminal server if I start client A and then start client B, if I try to print from client A this will lock both client A and B. If I kill client B from task manager, the other client will continue but I get the -30 error. However, if I shut everything down and restart if I print from client B it will work fine. The errors only start to happen when I print from the client that started first, client A. It is almost like something is happening at initialization where client B is steping on client A.
chopsdogg
Posts: 16
Joined: Mon Dec 27 2004

Post by chopsdogg »

A bit more information. Even though I am starting the print job on client A, the EnablePre is firing on client B. I believe this is directly the cause for the problem?
chopsdogg
Posts: 16
Joined: Mon Dec 27 2004

Post by chopsdogg »

Per the documentation

"When the message broadcast option is set in the Document Converter products, the printer driver broadcasts messages to all
running applications each time one of the following events occur:
Printer Enabled
Start of document
Start of page
End of page
End of document"

It doesn't seem that EnabledPre is getting fired on both clients running on the same terminal server. In fact when I print from client A, the event is only being fired on client B.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Re: Terminal Server and Printer not activated -30

Post by Joan »

Hello,

The GLock is a General Lock() method, it globally locks all methods that modify the registry, and makes them accessible only by the calling thread.

We recommend our users to use Lock()/Unlock and not GLock()/GUnlock(). GLock() gives the calling thread a system wide exclusive access to the methods and properties of CDIntf, until GUnlock is called. It can easily deadlock the system, and its functionality is not really needed in most cases.

I am adding here some more explanation about the locking feature mainly Lock()/Unlock()
Locking features.

Since the settings of the PDF printer are global in the registry, we need to synchronize access to it when dealing with multithreads printing. The Lock Unlock methods accomplish that by instructing the spooler to get the settings per job, by its job name/id.

What Lock does actually is reserve a private area where the settings for that specific job would go. SetDocFileProps would set the preferences for the job. When the job is being printed the spooler gets the settings for that job, and then deletes that private place.
What Unlock does is simply delete that private area in case the print job / spooler failed.
The Unlock timeout value hence should be very large, to give enough time for the job to finish printing. Even if unlock was not called, the print spooler unlocks the reserved area as soon as it retrieves the needed settings from it.
In case of 2 print jobs having the same job name, they are serialized, one after the other.
Other than that, print jobs can ran simultaneously, each taking its settings from its private reserved area.

For the Lock/Unlock to work as expected, the return value should be checked.
----------------------------------------------------------------------------------
do
{
iRet = Lock(jobname)
if (lock failed but did not timeout)
handle failure
}while ((Lock did timeout) && (we don't want to cancel yet))

Now, we either have a lock or we did cancel

Print Print Print
----------------------------------------------------------------------------------

So basically, the return errors of lock are as follows:

0 ==> success
-1 ==> operation timed out (we should not continue, but try again)
< -1 ==> failed

So the pseudo becomes:
do
{
iRet = Lock(doctitle)
if (iRet < -1)
handle failure
}while ((iRet == -1) && (we don't want to cancel))
After this loop we are sure that we either have a lock, or we have canceled.
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html

Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
chopsdogg
Posts: 16
Joined: Mon Dec 27 2004

Re: Terminal Server and Printer not activated -30

Post by chopsdogg »

Thank you for the reply. Any idea why EnabledPre fires on Client B, when Client A tries to print (see above)? This seems to be my problem right now, as I am enabling the printer in my EnabledPre event, but when I print in Client A I never get the EnabledPre event in Client A to activate the printer and then receive the -30 error. The EnabledPre event fires off in Client B instead.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Re: Terminal Server and Printer not activated -30

Post by Joan »

Are you running two different instances of the same application on clients A and B?

Are you calling EnablePrinter() when getting the EnablePre() event?

Are you doing any processing during the EnablePre() event other than enabling the printer?

I suggest that you replace GLock/GUnlock byt Lock/Unlock functions

General Note:
EnablePre is used to enable the printer, there's nothing wrong with this. This event means the printer needs to be enabled, it is caught by all applications using this printer.
different applications (not instances of same app) should use different printernames
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html

Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
chopsdogg
Posts: 16
Joined: Mon Dec 27 2004

Re: Terminal Server and Printer not activated -30

Post by chopsdogg »

First of all, we are looking in to using LOCK vs GLOCK, but I want to be clear I don't think our issue has to do with locking. It happened before we tried to implement locking, and is why we started investigating implementing locking for the PDF Converter in our application to begin with. Now that I have more information, I am not sure if locking is the issue at all.

On a regular Windows XP machine, single user, our EnabledPre event is firing fine when we go to print to the printer and we are able to call EnablePrinter in the EnabledPre event to activate the printer and print with no errors. This is the only processing we are doing in EnabledPre, a single line of code to call EnabledPre and again it seems to work fine in a single user environment.

However, we have the same application test.exe installed on Windows Terminal Server. We install the PDF Converter as TESTPDFWRITER permanently on the Windows Terminal Server with the application.

So, User A logs in to a Terminal Server session and starts up test.exe (Client A). User A is able to print to the TESTPDFWRITER through test.exe just fine.

User B then logs in to a second Terminal Server session on the same machine and also starts test.exe (Client B). User B can print to TESTPDFWRITER through test.exe just fine.

After User B logs in and while User B is still logged in, User A tries to now print again. User A tries to print to TESTPDFWRITER through test.ext, but immediately gets a -30 error indicating the printer is not activated. In testing by adding some debugging code I can see that the EnabledPre event actually gets raised in User B's process (Client B), and we can EnablePrinter in User B's process. However, User A already gets an error that the printer is not activated and the EnabledPre event is never raised in User A’s process.

The documentation seems to say that all processes should get the event, but this does not seem to happen. I am assuming that the process for User A is trying to actually print before the process for User B actually gets to call EnablePrinter and thus causing the error in User A's session that the printer is not activated. Although I am just guessing, and looking more for guidance about how to fix this.

Thank you for your help with this. We have been struggling with resolving this for a while, and otherwise the product is working pretty well for us.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Re: Terminal Server and Printer not activated -30

Post by Joan »

Hello,

I will need to check what the EnablePre() is not fired on Client A.

Please let me know when you are calling EnablePrinter() function in your application.

Thanks,
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html

Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
chopsdogg
Posts: 16
Joined: Mon Dec 27 2004

Re: Terminal Server and Printer not activated -30

Post by chopsdogg »

FYI, I am no longer getting notifications when a reply is posted to my thread.

We are calling EnablePrinter() when we catch the EnabledPre() event. Sorry if I was not clear about this above. Here is the code in our EnabledPre() which works fine for a single client. Note that PDFDEF.H just has the definitions for AmyuniLicenseCompany & AmyuniLicenseCode for activation as well as for different flags, etc for file options. This is the only code in the EnabledPre() event.

*** ActiveX Control Event ***
*** Event fired by Amyuni PDF Creator just before it checks to see if product is activated/enabled.
#INCLUDE INCLUDE\PDFDEF.H
THIS.EnablePrinter(AmyuniLicenseCompany, AmyuniLicenseCode)

In testing, I put an additional line of code in here that would tell me which client on the terminal server was getting the EnabledPre event. I wanted to make sure it was still firing when multiple clients were running on the same terminal server, and this is when I found that the event only fired for client B.
Joanna
Site Admin
Posts: 3
Joined: Wed Oct 02 2002
Contact:

Re: Terminal Server and Printer not activated -30

Post by Joanna »

Hello,

Sorry for the delay in getting back to you. Maybe you already send an email to our Support Team and get a reply on this issue.

Under terminal services one session cannot enable the printer in a different session. This would cause the activation timeout errors that they are encountering.


In a situation like this, we would need to find out more about your application (i.e. what does your application do?)

Is your application a document management system? When you are capturing events, are you allowing users to print from other application than yours to the PDF Converter?
Post Reply