Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 20 of 28 total
Thread 1107 The session ID 4 is no longer present on the server
Wed, Jan 6 2016 3:22 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

><< OK question clarification - how do I find out the error number so I decide how I want to react? >>
>
>Error number for what, exactly ? The Winsock send/receive error ?

The log file quotes error 1107 - its that number I want. The OnRemoteReconnect event only has (Sender: TObject; var Continue, StopAsking: Boolean); as parameters so what I need is how to find the 1107.

Roy Lambert
Wed, Jan 6 2016 3:32 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

>202 An error occurred with the module nlhFunctions (Access violation at address 04104B8C. Read of address 04104B8C)
>
>The bit that really baffles me is the logout from the background session. The only thing I can find where the session is closed is if I terminate the thread. If I've done that why is it trying to load the module? >>
>
>Okay, you'll need to give me some information here. Where is the background session being created, in your external module ? If so, then there may be an issue with your code in the module.

Nope, the external module only contains (fairly simple)  support functions. The route goes

TTfRBackgroundForm <<<<<<<<< app main form
    TEMailUIFrame <<<<<<<<< embedded main UI frame
          Controller: TnlhButton; <<<<<<<<< a button that in its OnClick event creates the thread
             TBackgroundEMail <<<<<<< background thread

The whole thing runs fine most of the time, but I'm getting this session has vanished problem occasionally.

Roy Lambert
Wed, Jan 6 2016 8:55 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< The log file quotes error 1107 - its that number I want. The OnRemoteReconnect event only has (Sender: TObject; var Continue, StopAsking: Boolean); as parameters so what I need is how to find the 1107. >>

There is no way to retrieve that error code from the OnRemoteReconnect event handler.   The 1107 error happens *after* the OnRemoteReconnect is fired and your code indicates yay or nay if you want to reconnect.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jan 6 2016 8:57 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< Nope, the external module only contains (fairly simple)  support functions. >>

It must contain more than that - you're getting an AV in it.

<< The route goes >>

Where is this located, in the client ?  If so, then you need to make sure that you're not messing something up with the threading.

<< The whole thing runs fine most of the time, but I'm getting this session has vanished problem occasionally. >>

That's got "race condition" written all over it. Smile

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jan 6 2016 9:46 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

><< The log file quotes error 1107 - its that number I want. The OnRemoteReconnect event only has (Sender: TObject; var Continue, StopAsking: Boolean); as parameters so what I need is how to find the 1107. >>
>
>There is no way to retrieve that error code from the OnRemoteReconnect event handler. The 1107 error happens *after* the OnRemoteReconnect is fired and your code indicates yay or nay if you want to reconnect.

OK any suggestion on where / how I can react to the 1107 error then?

Roy Lambert
Wed, Jan 6 2016 10:11 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


>It must contain more than that - you're getting an AV in it.

I have just searched all of my units in this application for all of the functions in nlhFunctions. The only one called is

function BytesToKbMb(const NoOfBytes: integer): string;
const
GigaByte = 1024 * 1024 * 1024;
MegaByte = 1024 * 1024;
KiloByte = 1024;
begin
if NoOfBytes = 0 then Result := ''
else if NoOfBytes > (0.5 * GigaByte) then Result := Format('%8.1fGb', [NoOfBytes / GigaByte])
else if NoOfBytes > (0.5 * MegaByte) then Result := Format('%8.1fMb', [NoOfBytes / MegaByte])
else if NoOfBytes > KiloByte then Result := Format('%8.1fKb', [NoOfBytes / KiloByte])
else Result := Format('%8.0dBytes', [NoOfBytes]);
Result := Trim(Result);
end;

which is only called in one place

 sl.Add('Message size: ' + BytesToKbMb(Length(emText)));

Not sure how that can AV Smiley

Also don't forget this only appeared after I moved the server from 2.18 to 2.20. Before that it was

Close Session 9999 Access violation at address 00403F5E in module 'edbsrvr.exe'. Read of address 04204B8C 2015-12-29 23:52:29.102

><< The route goes >>
>
>Where is this located, in the client ? If so, then you need to make sure that you're not messing something up with the threading.

Yup, I may be messing something up but I don't think so.

><< The whole thing runs fine most of the time, but I'm getting this session has vanished problem occasionally. >>
>
>That's got "race condition" written all over it. Smile

Possibly, but I'm not sure what is racing or how to track it down.

Roy Lambert
Wed, Jan 6 2016 10:22 AMPermanent Link

Matthew Jones

Roy Lambert wrote:

>   sl.Add('Message size: ' + BytesToKbMb(Length(emText)));
>
> Not sure how that can AV Smiley

Easily. sl doesn't exist any more.



> TTfRBackgroundForm <<<<<<<<< app main form
>      TEMailUIFrame <<<<<<<<< embedded main UI frame
>            Controller: TnlhButton; <<<<<<<<< a button that in its
> OnClick event creates the thread               TBackgroundEMail
> <<<<<<< background thread

I don't understand this - how is your main form also a background form?
Or is that the call stack from top to bottom?

My thinking, having read half of this and applied my instinct (hard won
fear), is that the data module is closing but not completing.


> The only thing I can find where the session is closed is if I
> terminate the thread. If I've done that why is it trying to load the
> module?

What I've had a lot with internet things, is that you ask some
component to disconnect and tidy up, and it says "okay, all done" and
you free it, and then get on with other things, and then a thread that
it had for doing worker things comes by and says "okay, it is all done
now" and it calls an event on the component that doesn't exist any more
really, but your code thinks that since it has been called it must be
good, so you assume that it is, and kerboom! Except of course that
sometimes it seems to work, as the memory is still good.

This is why I like FreeAndNil as a standard, because you find out
immediately when something comes by later like this. Some (I'm looking
at you newsgroups of a certain organisation) will call this a code
smell. Me, I call it the only way to program in a sane manner in
complex code. Saved my bacon many times.

Anyway, must do some real work while you work out I'm talking nonsense.
8-)


--

Matthew Jones
Thu, Jan 7 2016 5:48 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Matthew



>Easily. sl doesn't exist any more.

>Anyway, must do some real work while you work out I'm talking nonsense.

I had that sussed as soon as I saw the name <VBG>

More seriously - its in the error logging bit which goes

end else begin
 sl := TStringList.Create;
 sl.Add(IntToStr(SendMail.ResultCode) + ': ' + SendMail.EnhCodeString);
 sl.Add('Message size: ' + BytesToKbMb(Length(emText)));
 Commons.MakeLogEntry(ltError, MailOut, 'ISP refused email', sl.Text, logPostingErrors);
 sl.Free;
end;

even if sl was being released and called I'd expect the AV to be from the calling program not the external function dll

The thread is only called once, nothing else uses its output (well the tables do get used outside the thread but are fully isolated) and it signals its termination back to the calling thread so that shouldn't do it.

<<This is why I like FreeAndNil as a standard,>>

Not to sure about as a standard but

procedure TBackgroundEMail.ReleaseService;
begin
KeepOn := False;
if Assigned(emSend) then FreeAndNil(emSend);
if Assigned(emReceive) then FreeAndNil(emReceive);
PostMessage(iParams.ReportBack, EMailServiceStopped, 0, 0);
end;

I'm beginning to wonder if its Delphi's exception handling (try..except) that's the problem so I'm going to $IFDEF all of those. Hopefully then the next time I'll get a useful report.

Roy Lambert
Thu, Jan 7 2016 10:20 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< The log file quotes error 1107 - its that number I want. The OnRemoteReconnect event only has (Sender: TObject; var Continue, StopAsking: Boolean); as parameters so what I need is how to find the 1107. >>

You can't, is the answer.  It's mostly irrelevant in the scope of the reconnects, anyways.  A better determination is how many reconnects have been attempted.  If the number is greater than 4-6, then most likely the connection is down for good.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jan 7 2016 10:30 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< Not sure how that can AV Smiley>>

Are you sure that's the only function being called ?

<< Also don't forget this only appeared after I moved the server from 2.18 to 2.20. Before that it was >>

It's probably the same thing.  I added additional error handling for the modules due to a customer having an issue with an external module that was causing some bad things to happen during session shutdown when there was an AV in an external module.  This is basically the problem with external modules (for us):  because they run in-process, they can take down the entire server if you're not careful with your code.  I opted for this model instead of something like SQL Server, which has process separation, for performance reasons.

<< Possibly, but I'm not sure what is racing or how to track it down. >>

How many users are using the system at a given time ?  Is there a time when there are more users than normal ?  That's where I would start looking.  If there's a race condition, then it will normally happen with more activity.

If you want to send me your log (edbconfig.edblog), I can take a look and tell you what I think is happening.

Tim Young
Elevate Software
www.elevatesoft.com
« Previous PagePage 2 of 3Next Page »
Jump to Page:  1 2 3
Image