Random Error: 800403E9

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
User avatar
jimimaseye
Moderator
Moderator
Posts: 8777
Joined: 2011-09-08 17:48

Random Error: 800403E9

Post by jimimaseye » 2017-08-09 00:56

Friends, I just received this error:
"ERROR" 4840 "2017-08-08 22:58:28.767" "Script Error: Source: hMailServer COM library - Error: 800403E9 - Description: An error occurred processing the request. - Line: 811 Column: 3 - Code: (null)"
Line 811 of my eventhandlers script is part of Sorens 'GeoAutoban' (that blocks connections) as follows:

Code: Select all

Function GeoAutoban(oClient)
   ' COM authentication
   Const ADMIN = "Administrator"
   Const PASSWORD = "password"
   Dim obApp : Set obApp = CreateObject("hMailServer.Application")
   Call obApp.Authenticate(ADMIN, PASSWORD)

   Include(obApp.Settings.Directories.EventDirectory & "\VbsJson.vbs")     <<<<<<<<<<<<<<<------     line 811
   Dim strRegEx

   If (oClient.Port <> 25) then
      Dim oGeoip, Json : Set Json = New VbsJson
      Dim strPort : strPort = Trim(Mid("SMTP IMAP SMTPSsm587IMAPS", InStr("25   143  465  587  993  ", oClient.Port), 5))
      On Error Resume Next
Now this thing has been running day in day out for the last dont know how many weeks and is pretty much an untouched server. And yes, the 'VbsJson.vbs' file does exist in the Eventdirectory (otherwise it would never have been working). Most recent entries (and proof of it working) from 01:20 this morning:


3088 "2017-08-04 03:17:27.831" "status:200--IMAP 45.55.21.112 US United States"
4216 "2017-08-05 04:06:47.308" "status:200--IMAP 45.55.21.197 US United States"
4056 "2017-08-05 10:01:53.407" "status:200--IMAP 158.85.81.114 CA Canada"
4396 "2017-08-06 23:10:52.240" "status:200--sm587 151.216.93.11 "
3144 "2017-08-07 01:20:17.507" "status:200--IMAP 141.212.122.32 US United States"
Any clues what this error could be? Why would it give this error now? What does this error "Error: 800403E9 while processing" mean?
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
mattg
Moderator
Moderator
Posts: 21106
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Random Error: 800403E9

Post by mattg » 2017-08-09 01:15

E800xxxx errors are usually permissions based

My guess is that the VBS was locked, and was inaccessible, probably due to already being in use a few times simultaneously by your script
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
jimimaseye
Moderator
Moderator
Posts: 8777
Joined: 2011-09-08 17:48

Re: Random Error: 800403E9

Post by jimimaseye » 2017-09-04 08:39

Ive had another on of these again.

So my question is this (probably best directed to SorenR):

We already have the 'Lockfile' function in place:
[code]
Function LockFile(strPath)
Const Append = 8
Const Unicode = -1
With CreateObject("Scripting.FileSystemObject")
Dim oFile, i
For i = 0 To 30
On Error Resume Next
Set oFile = .OpenTextFile(strPath, Append, True, Unicode)
If (Not Err.Number = 70) Then
Set LockFile = oFile
On Error Goto 0
Exit For
End If
On Error Goto 0
Wait(1)
Next
End With
Set oFile = Nothing
If (Err.Number = 70) Then
EventLog.Write("ERROR: EventHandlers.vbs")
EventLog.Write("File " & strPath & " is locked and timeout was exceeded.")
Err.Clear
ElseIf (Err.Number <> 0) Then
EventLog.Write("ERROR: EventHandlers.vbs : Function LockFile")
EventLog.Write("Error : " & Err.Number)
EventLog.Write("Error (hex) : 0x" & Hex(Err.Number))
EventLog.Write("Source : " & Err.Source)
EventLog.Write("Description : " & Err.Description)
Err.Clear
End If
End Function[/code]


is there any way top stop this random error happening by incorporating the above LockFile function? (I also have a "Function OpenMyFile(strPath, ioMode)" function flying around as well - looks similar but not sure which is best).

How do we change this:
Function GeoAutoban(oClient)
.
Include(obApp.Settings.Directories.EventDirectory & "\VbsJson.vbs")
.
.
to use the lockfile function and stop it occasi0noally throwing this random error? (Im aware we are only trying to open/incorprate this JSON file and not actually open it to append to it - so not sure its suitable)
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
SorenR
Senior user
Senior user
Posts: 3826
Joined: 2006-08-21 15:38
Location: Denmark

Re: Random Error: 800403E9

Post by SorenR » 2017-09-05 16:07

You need to rearrange your eventhandler... These are the first 35 lines of mine...

By running the Include function in the script body means the Json object is loaded when the script is reloaded, so therefore available to all Sub's and Function's.

You _can_ solve the problem by using filelocking, but it is an unnecessary complication.

Code: Select all

Option Explicit

'  *****************************************************************************
'  ********** Settings                                                **********
'  *****************************************************************************

   ' COM authentication
   Private Const ADMIN = "Administrator"
   Private Const PASSWORD = "You wish :-)"

   Include("C:\hMailServer\Events\VbsJson.vbs")

   Function Include(sInstFile)
      Dim f, s, oFSO
      Set oFSO = CreateObject("Scripting.FileSystemObject")
      On Error Resume Next
      If oFSO.FileExists(sInstFile) Then
         Set f = oFSO.OpenTextFile(sInstFile)
         s = f.ReadAll
         f.Close
         ExecuteGlobal s
      End If
      On Error Goto 0
      Set f = Nothing
      Set oFSO = Nothing
   End Function

'  *****************************************************************************
'  ********** Classes                                                 **********
'  *****************************************************************************

   Class MyToolBox
      Public EventLog
      Private m_InitCOM, m_Admin, m_Password, m_Server, m_LogFile, m_LogType, ...
      Private i, t, temp, strDay, strMonth, strTime, strLogFile, strLogDate
      ....
      ....
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

User avatar
jimimaseye
Moderator
Moderator
Posts: 8777
Joined: 2011-09-08 17:48

Re: Random Error: 800403E9

Post by jimimaseye » 2017-09-06 09:20

Hmmmm... I did that then ran in to a load of problems (I got errors, IOCP runaways etc).

Remind me: you did a test once an proved that the whole contents of the eventhandlers script was load from fresh on every message, right?

Well given that my machine does external downloads of its messages I wonder it is firing this authentication line for each and every message it checks (the same time I get hundreds of 'External Download' events for every message that exists on the host server) and therefore it tries to do this authentication for EVERY message on the host server?
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
SorenR
Senior user
Senior user
Posts: 3826
Joined: 2006-08-21 15:38
Location: Denmark

Re: Random Error: 800403E9

Post by SorenR » 2017-09-06 14:22

The difference on your code and my code is that I use a hardcoded link to the Json code.

I see no reason for building a link from "variables" as the code is not going to move to a different directory/drive on its own anyway - and if does, it's probably because you messed up your installation ;-)

I did some further testing today with SysInternals FileMon... Yes it is loaded everytime a session is connected that require a script, regardless of where in the code you place it. As a side effect I found that FileMon causes havoc with hMailServer filehandling on received emails - so, deffo' not reccomended !! :roll:
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

User avatar
SorenR
Senior user
Senior user
Posts: 3826
Joined: 2006-08-21 15:38
Location: Denmark

Re: Random Error: 800403E9

Post by SorenR » 2017-09-06 14:39

Correction... I forgot to "rem" the common line of code when testing "Include" from a sub ... :oops:

Will do some further experiments - unfortunately my system is not prepaired for generating SPAM and unsoliced requests so I have to wait for real life events... :wink:
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

User avatar
jimimaseye
Moderator
Moderator
Posts: 8777
Joined: 2011-09-08 17:48

Re: Random Error: 800403E9

Post by jimimaseye » 2017-09-06 14:57

Cheers

Just so I am clear:

All my email comes in via External Download with a 1 month retention before deletion from the host server. Therefore, if debug logging was enabled I get:
[code]"DEBUG" 6072 "2017-09-06 13:48:13.943" "Executing event OnExternalAccountDownload"
"DEBUG" 6072 "2017-09-06 13:48:13.943" "Event completed"
"DEBUG" 6072 "2017-09-06 13:48:13.943" "Executing event OnExternalAccountDownload"
"DEBUG" 6072 "2017-09-06 13:48:13.943" "Event completed"
"DEBUG" 6072 "2017-09-06 13:48:13.943" "Executing event OnExternalAccountDownload"
"DEBUG" 6072 "2017-09-06 13:48:13.943" "Event completed"
"DEBUG" 6072 "2017-09-06 13:48:13.943" "Executing event OnExternalAccountDownload"
"DEBUG" 6072 "2017-09-06 13:48:13.943" "Event completed"
"DEBUG" 6072 "2017-09-06 13:48:13.943" "Executing event OnExternalAccountDownload"
"DEBUG" 6072 "2017-09-06 13:48:13.943" "Event completed"
"DEBUG" 6072 "2017-09-06 13:48:13.943" "Executing event OnExternalAccountDownload"
"DEBUG" 6072 "2017-09-06 13:48:13.958" "Event completed"
"DEBUG" 6072 "2017-09-06 13:48:13.958" "Executing event OnExternalAccountDownload"
"DEBUG" 6072 "2017-09-06 13:48:13.958" "Event completed"
"DEBUG" 6072 "2017-09-06 13:48:13.958" "Executing event OnExternalAccountDownload"
"DEBUG" 6072 "2017-09-06 13:48:13.958" "Event completed"
"DEBUG" 6072 "2017-09-06 13:48:13.958" "POP3 External Account: Normal QUIT."
[/code]


where the COUNT of "Executing event OnExternalAccountDownload" equals the totoal amount of emails on the host server (all of which that have already previously downloaded).

I was wondering whether this means that

(a) for every message it is loading up the eventhandlers script each time (so therefore in the above example there would be 8 loads of it) or
(b) whether it loads it once per connection to the host server (with one global authentication and then of which the subevent of 'OnexternalDownload' is called upon 8 times).

If it is (a) then it would mean 8x fast load and authentications of the app in quick succession (followed by whatever other scripting sub events are called) and you can imagine that in reality, with the server holding hundreds of emails within the last 30 days, that is a heavy load and the cause for the errors I had.

So is it (A) or (B) ?
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
SorenR
Senior user
Senior user
Posts: 3826
Joined: 2006-08-21 15:38
Location: Denmark

Re: Random Error: 800403E9

Post by SorenR » 2017-09-06 15:36

Just finished testing...

I only use GeoIP lookups when doing my selective AutoBanning, so I moved the statement ...

Include("C:\hMailServer\Events\VbsJson.vbs")

... into my "Sub AutoBan...." code.

Experiments with SysInternals FileMon show:

hMailServer - Program start -> VbsJson.vbs NOT READ from disk
hMailServer Admin - script reload -> VbsJson.vbs NOT READ from disk
hMailServer - Script execution of AutoBan -> VbsJson.vbs READ from disk

Thus I can assume VbsJson.vbs in ONLY read when needed and NOT on every call to the EventHandler.vbs.

I have revised my production EventHandler.vbs accordingly.

Getting back to your issue with errorcode 800403E9 ... Try a hardcoded link to VbsJson.vbs

viewtopic.php?p=71903#p71903
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

User avatar
jimimaseye
Moderator
Moderator
Posts: 8777
Joined: 2011-09-08 17:48

Re: Random Error: 800403E9

Post by jimimaseye » 2017-09-06 22:26

I have moved it back to the Sub Autoban section too.

I had no doubt that it was only called upon when a qualifying message was triggering it (as per your findings).

Im guessing the rare but random occasions of the 800403E9 will remain exactly that: rare and random (a bit weird though).
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
mattg
Moderator
Moderator
Posts: 21106
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Random Error: 800403E9

Post by mattg » 2017-09-07 01:49

jimimaseye wrote:where the COUNT of "Executing event OnExternalAccountDownload" equals the totoal amount of emails on the host server (all of which that have already previously downloaded).
I didn't realise this.
I though that 'OnExternalAccountDownload' triggered for each download 'event', but I see that you are correct, it is for each message. This explains some anomalies that I had noticed with this event.
jimimaseye wrote: I was wondering whether this means that

(a) for every message it is loading up the eventhandlers script each time (so therefore in the above example there would be 8 loads of it) or
(b) whether it loads it once per connection to the host server (with one global authentication and then of which the subevent of 'OnexternalDownload' is called upon 8 times).

If it is (a) then it would mean 8x fast load and authentications of the app in quick succession (followed by whatever other scripting sub events are called) and you can imagine that in reality, with the server holding hundreds of emails within the last 30 days, that is a heavy load and the cause for the errors I had.

So is it (A) or (B) ?
I think neither.

I think that the eventhandlers.vbs is loaded into memory at start-up or reload of scripts, and that the scripts run from cached memory when the 'events' are triggered.
If your sub loads some external code, then this would be loaded EACH running of that sub.

If you do as SorenR was doing
SorenR wrote:By running the Include function in the script body means the Json object is loaded when the script is reloaded, so therefore available to all Sub's and Function's.
Then I think that the Json Object is ONLY loaded at startup, or reload of scripts, and is also retained in cache memory
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
jimimaseye
Moderator
Moderator
Posts: 8777
Joined: 2011-09-08 17:48

Re: Random Error: 800403E9

Post by jimimaseye » 2017-09-07 08:40

mattg wrote: If you do as SorenR was doing
SorenR wrote:By running the Include function in the script body means the Json object is loaded when the script is reloaded, so therefore available to all Sub's and Function's.
Then I think that the Json Object is ONLY loaded at startup, or reload of scripts, and is also retained in cache memory
But this is why I am confused. My original problem (of this thread) is random and is thought to be a permission problem. As the JSON is permanently resident, (no AV in place), and always called upon only when there is a qualifying message to call upon it, then I can only think that the error was a bottleneck (filelock) on the file possibly by 2 message at the same time calling upon it. And if it was held in memory then there wouldnt be a filelocking problem, therefore it must be loading from disk each time it is required. And that then suggests a confirmation of the next point:
I think that the eventhandlers.vbs is loaded into memory at start-up or reload of scripts, and that the scripts run from cached memory when the 'events' are triggered.
Im pretty sure that Soren did a test in the last year or so and discovered that the whole evenhandlers script was reloaded for each event (albeit loaded from memory cache as provided by the 'reload' button). We were surprised to this as we thought the same as you are saying and that but turns out not (it was done to prove/disproved whether putting the authentication details as a global variable made a difference in being a 'fire only once at startup' kind of way - and it doesnt.)

(I might be wrong - my memory might be failing me and Im al confused. I wouldnt mind finding the thread Im thinking of or maybe this rings a bell to Soren and he can remember his findings).
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
SorenR
Senior user
Senior user
Posts: 3826
Joined: 2006-08-21 15:38
Location: Denmark

Re: Random Error: 800403E9

Post by SorenR » 2017-09-07 11:39

mattg wrote:If you do as SorenR was doing
SorenR wrote:By running the Include function in the script body means the Json object is loaded when the script is reloaded, so therefore available to all Sub's and Function's.
Then I think that the Json Object is ONLY loaded at startup, or reload of scripts, and is also retained in cache memory
If you read my test a few posts back you'll find the answer to this...

Eventhandlers.vbs is run at EVERY and ALL scriptevent, thus code placed (in the body) outside CLASS, SUB or FUNCTION is executed at ALL scriptevents. SUB, CLASS and FUNCTION is naturally ONLY executed WHEN CALLED.
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

User avatar
SorenR
Senior user
Senior user
Posts: 3826
Joined: 2006-08-21 15:38
Location: Denmark

Re: Random Error: 800403E9

Post by SorenR » 2017-09-07 11:43

mattg wrote:If you do as SorenR was doing
SorenR wrote:By running the Include function in the script body means the Json object is loaded when the script is reloaded, so therefore available to all Sub's and Function's.
Then I think that the Json Object is ONLY loaded at startup, or reload of scripts, and is also retained in cache memory
If you read my test a few posts back you'll find the answer to this...

Eventhandlers.vbs is run at EVERY and ALL scriptevent, thus code placed (in the body) outside CLASS, SUB or FUNCTION is executed at ALL scriptevents. SUB, CLASS and FUNCTION is naturally ONLY executed WHEN CALLED.

Syntax check as per Admin GUI I found a bit trickey... If Include(bla bla) was placed in the body of the script, it too was read and syntax checked.
If Include(bla bla) was placed inside a SUB then it was NOT read and thus NOT syntax checked.

Anyways, just an observation.
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

User avatar
mattg
Moderator
Moderator
Posts: 21106
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Random Error: 800403E9

Post by mattg » 2017-09-08 01:15

You mean this test?
SorenR wrote:Just finished testing...

I only use GeoIP lookups when doing my selective AutoBanning, so I moved the statement ...

Include("C:\hMailServer\Events\VbsJson.vbs")

... into my "Sub AutoBan...." code.

Experiments with SysInternals FileMon show:

hMailServer - Program start -> VbsJson.vbs NOT READ from disk
hMailServer Admin - script reload -> VbsJson.vbs NOT READ from disk
hMailServer - Script execution of AutoBan -> VbsJson.vbs READ from disk

Thus I can assume VbsJson.vbs in ONLY read when needed and NOT on every call to the EventHandler.vbs.
Is that the same result if the call to JSON is outside of all Subs, just in eventhandlers main

should this be 'ONLY read when needed (when in a sub)'
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
SorenR
Senior user
Senior user
Posts: 3826
Joined: 2006-08-21 15:38
Location: Denmark

Re: Random Error: 800403E9

Post by SorenR » 2017-09-08 02:05

Ok... long story cut short.

Code in Eventhandlers.vbs "body" allways run. Code in Sub/Class/Function only run when called.

Eventhandlers.vbs is run at every event.

Ok?
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

User avatar
jimimaseye
Moderator
Moderator
Posts: 8777
Joined: 2011-09-08 17:48

Re: Random Error: 800403E9

Post by jimimaseye » 2017-09-08 08:28

mattg wrote: should this be 'ONLY read when needed (when in a sub)'
Yes, it should bve put in the sub otherwise it will be evaluated and ran at every event even if the event (one of the subs such as onClientConnect etc) isnt going to use it.

What it measn is that putting code outside of any sub will always be ran and evaluated from fresh on each and every event before the event (sub)itself is then called and that the only benefit in puttoing something outside the event is to save having to code in your password to authenticate the hmailserver application object. What what if the event isnt going to NEED that object? - that will be a waste of resources. (Remeber, for example, the OnExternalDownload example - that would mean authenticating the object to create (for example) 'oApp' for each and every email is see on the host server just for nothing to then happen. Wasteful. From what I saw and understood it concluded that putting things outside of subs/functions was a waste of resources and possible harmful (as proven by my OnExternalDownload example above). Maybe the application authentication should be a function which is then called by your subs that need it (and leave the 'global' patyt of the evenhandlers script blank.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

Post Reply