Agent RunOnServer Hangs connecting to DB2

We are exepriencing a problem where the Notes client hangs while trying to connect to DB2 in an agent that is “run on the server”. The agent is called from the button click event of a form. We have tested/debuged the code up to the connection.connectto() call using print statements to the Notes log and the code is working fine, however when it gets to the connectto call the client hangs and we have to reboot the machine.

We have made sure that that ODBC is properly configured and tested the database connection on the server. HOWEVER, to test further, we set up our same problem agent to run as scheduled, and this it ran through the connectto call just fine.

Is there any known reasons why running an agent on the server using LSODBC operations/functions would cause the described problem?

Thanks.

Subject: Agent RunOnServer Hangs connecting to DB2

I have posted this under another topic. This problem may not lie within Agent.RunOnServer() method, but in the IP routing between our firewall and mainframe.

Please see:

http://www-10.lotus.com/ldd/nd6forum.nsf/DateAllThreadedweb/fefb9265da2952c685256fee0054d4b8?OpenDocument

Subject: RE: Agent RunOnServer Hangs connecting to DB2

I had exactly the same problem and found that the server was running under a specific username/password (it is configured under the Control Panel - Services Lotus Domino server properties).

My SQL Db Administrator ensured that this user has full access to the external database, and voilá, it started working.

Don’t ask me why it works as a scheduled agent, though…

Subject: Agent RunOnServer Hangs connecting to DB2

Check the things that are different between running the agent on the client and server: security and mapped drives

Subject: RE: Agent RunOnServer Hangs connecting to DB2

Before trying to schedule the agent, we set the agents security options to “Run with full Administrator rights”, and had the agent signed by the Notes admin. Yet, the agent still failed.

When we scheduled the agent we ran it signed by a developers id and it ran OK. There are no drive mappings or attempted I/O’s to the file system inside the agent.

Here is the agent :

===========================

Sub Initialize

Print “Starting DB2 Insert Agent”

Dim session As New NotesSession

Dim doc As NotesDocument

Dim pdoc As NotesDocument

Dim db As NotesDatabase

Dim agent As NotesAgent

Set con = New ODBCConnection

Print “Connect ODBC”

Set query = New ODBCQuery

Set data = New ODBCResultSet

Set db = session.CurrentDatabase

Set agent = session.CurrentAgent

Set pdoc = db.GetDocumentByID (agent.ParameterDocID)

Set doc = db.GetDocumentByUNID(pdoc.DocId(0))

Set query.connection = con

Set data.query = query

Print “About to connect to CNSW44.CNSNWI”

If Not con.ConnectTo(DB2DB, UID, PWD) Then

Print "Could not connect to DSNU"

Exit Sub

End If

Print “Connected to DSNU”

sql = "Insert into CNSW44.CNSNWI (CPY_CD, DOC_ID, MTN_TYP, FAC_WHS, BYR_CD, VEN_NBR, " & _

"RTL_UNT_STR_CSE, ITM_SIZ_DSC, ITM_DSC, CSE_LEN, CSE_WDT, CSE_HGT, CSE_WGT, " &_

"CSE_PER_LAY, LAY_PER_PAL, LA_TAX_FLD, TX_TAX_FLD, PPR_FLD, BON_PAC_FLD, " &_

"EST_ARR_DT, FRT_ALW_TYP, FRT_ALW, CSE_CST, CSE_GTIN, PRD_GTIN) " &_

"values('G', '" & doc.UniversalID & "','N', '   ', '" & _

doc.GSCBuyerCode(0) & "','" & doc.VendorNumber(0) & "'," & doc.BPack(0) & ",'" & doc.BSize(0) & "','" &_

doc.BDesc(0) & "','" & doc.BCaseLength(0) & "','" & doc.BCaseWidth(0) & "','" & doc.BCaseHeight(0) & "','" &_

doc.BCaseWeight(0) & "','" & doc.BTI(0) & "','" & doc.BHI(0) & "','" & doc.BLaTaxable(0) & "','" &_

doc.BTaxable(0) & "','" & doc.BPrePriced(0) & "','" & doc.BBonusPack(0) & "','" & doc.BArrivalDate(0) & "','" &_

doc.BAllowType(0) & "','" & doc.BAllowance(0) & "','" & doc.BPOCost(0) & "','" & doc.BCaseGTIN(0) & "','" &_

doc.BProdGTIN(0)   & "')"



query.sql = sql

REM Msgbox sql,“Test”

If Not data.Execute Then

Print "Not OK, Could not Connect!"

	error% = data.GetError

	message$ = data.GetErrorMessage(error%)

	ExtendedMessage$=data.GetExtendedErrorMessage(error%)

Print message$ 

Print "Error Code: " & Str$(error%)

Print "Extended Error: " & ExtendedMessage$ 

Exit Sub

End If

End Sub

Subject: RE: Agent RunOnServer Hangs connecting to DB2

As a guess it looks like the user trying to access the DB2 system doesn’t have the access rights to do so in this instance. When the agent runs on the server it runs with the access rights of the person who signed it (or the server, or the run as I am not sure)

Subject: RE: Agent RunOnServer Hangs connecting to DB2

I also got the same problem up to the place where it’s trying to make connection to a datasource. As what you have done I have scheduled this agent, it worked fine, but failed when using the same code in an agent initiated by calling the RunOnServer agent method.

I am also sure it’s not to do with the access rights as I am the signer of all the agents.