Re: [twsocket] No response problem [THttpServer - TCustomLineWSocket]

2005-06-21 Thread Christophe
Ok, thanks so much. I made the changes and it works (though I didn't 
tested extensively yet).


For reference, this is what I did:
- use of Connection.PostedDataReceived in the PostedData-event
- I don't use LineMode at all (no change if I do)
- Changing the way I was answering to GET commands from SendStream to 
AnswerString. I guess my calculation of the size in the header was 
wrong. Anyway it simplifies the code.


I did ICS updates frequently, but I realized I didn't checked the new 
webserv demo correctly. I didn't know at all for the AnswerString 
function, for example. And if my memory is correct I never used 
PostedDataReceived either. First time I downloaded ICS was maybe 4 years 
ago or something ;-)


Anyway, it works now, it seems.

Thanks to all the people who help me on this, and a special thanks to 
Francois (BTW I won't publish the code since this problem is solved...)


Christophe

Bjørnar Nielsen wrote:
I checked this and I am pretty sure it happens only on second 
time connections. When I first do a GET or POST, it always works.



Just out of my head, here is som possible reasons that maybe can cause your
problem.

- The header you generate has wrong content length that tells the length of
the body you send.
- You don't provide a content length in your header, in that case the
browser don't know that he has received all data untill you close the
connection.
- You don't call Connection.PostedDataReceived when all data is received
inside PostedData-event.

If you close the connection, then you should also indicate this happening in
the header (Connection: Close, instead of Connection: Keep-Alive)

Regards
Bjørnar






--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


RE: [twsocket] No response problem [THttpServer - TCustomLineWSocket]

2005-06-20 Thread Bjørnar Nielsen
 When users clicks links or post forms in their browsers, 
 sometimes they don't get any answer. By debugging the server 
 I realized that in such a case the OnPostDocument event is 
 never triggered.

Are you sure the request you don't get an answer from is received on the
server?

When you run a server on a non-server-platform you might miss some requests
when many requests arrive at the same time. On a non-server-platform (w2000,
XP etc) there is a listen backlog set to 5. That means that 5 connects is
queued by the os if your server is not ready to accept the connection yet.
The sixth connection will be lost. On a server-platform (w2000 server, w2003
server etc), this backlog is set to 200.

Regards
Bjørnar



--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] No response problem [THttpServer - TCustomLineWSocket]

2005-06-20 Thread Francois Piette
The first important thing is: Are you using the very latest ICS version 
downloaded from my website ?

 When users clicks links or post forms in their browsers, sometimes they 
 don't get any answer. By debugging the server I realized that in such a 
 case the OnPostDocument event is never triggered.

Do you have a reproductible case ?
Does it occurs with the sample WebServ delivered with ICS ?

--
[EMAIL PROTECTED]
http://www.overbyte.be


- Original Message - 
From: Christophe [EMAIL PROTECTED]
To: twsocket@elists.org
Sent: Monday, June 20, 2005 4:01 AM
Subject: [twsocket] No response problem [THttpServer - TCustomLineWSocket]


 Hi,
 
 First of all, I'd like to apologize if my question is inapropriate, it 
 is the first time I am using a mailing list (I usually use php based 
 forums for development issues).
 
 I searched a lot about the following problem, but I still don't have a 
 clue of what's happening:
 
 I have been developping few applications that use the THttpServer 
 component. I noticed that sometimes (randomly), the server gives no 
 answer to clients.
 When users clicks links or post forms in their browsers, sometimes they 
 don't get any answer. By debugging the server I realized that in such a 
 case the OnPostDocument event is never triggered.
 
 I checked the call stack at that time, and it seems the problem is in 
 TCustomLineWSocket.TriggerDataAvailable (Unit WSocket). At the beginning 
 of this function there is the following test:
 if (not FLineMode) or (Length(FLineEnd) = 0) or (FSocksState  socksData)
 then begin
Result := inherited TriggerDataAvailable(Error);
Exit;
 end;
 
 I placed breakpoints and I am pretty sure that if FLineMode is false, 
 then there is no problem (the component will continue and send back data 
 to the client).
 If FLineMode is false, the component will stop here (after the Exit), 
 and will never send anything back to the client browsers (they wait, 
 and, after a while, they fail because of a timeout).
 
 It brings 2 questions:
 - For the same link (GET) or form (POST), why does sometimes FlineMode 
 is true and sometimes false ?
 - How to force FLineMode to be true, or more generally how to solve such 
 a problem. (I tried to do a (Client as THTTPConnection).LineMode:=true 
 in the OnClientConnect event but it doesn't change a thing).
 
 PS: It is the first time I checked ICS source, so my analysis of the 
 problem is maybe totally wrong.
 PS2: I tested this on two different PCs with WindowsXP (no firewall, no 
 antivirus) on a LAN. I re-downloaded ICS today to be sure, but the 
 problem is still there.
 
 Thank you,
 Christophe
 
 -- 
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] No response problem [THttpServer - TCustomLineWSocket]

2005-06-20 Thread Christophe

Bjørnar Nielsen wrote:
When users clicks links or post forms in their browsers, 
sometimes they don't get any answer. By debugging the server 
I realized that in such a case the OnPostDocument event is 
never triggered.



Are you sure the request you don't get an answer from is received on the
server?

Yes, as I explained in my last mail, when a user makes a request (GET or 
POST or HEAD or whatever), the server get it, and start to analyze it 
but stops inside TCustomLineWSocket.TriggerDataAvailable.



When you run a server on a non-server-platform you might miss some requests
when many requests arrive at the same time. On a non-server-platform (w2000,
XP etc) there is a listen backlog set to 5. That means that 5 connects is
queued by the os if your server is not ready to accept the connection yet.
The sixth connection will be lost. On a server-platform (w2000 server, w2003
server etc), this backlog is set to 200.


Well I can understand that, except that this problem occurs even when I 
do debugging (which means only one client, on the local machine). Also, 
I checked in the MS event manager (I guess if windows drops some 
connections it would place an entry here), but I found nothing.




Regards
Bjørnar






--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] No response problem [THttpServer - TCustomLineWSocket]

2005-06-20 Thread Christophe

Francois Piette wrote:

The first important thing is: Are you using the very latest ICS version 
downloaded from my website ?


Yes, I re-installed the last version this morning.



When users clicks links or post forms in their browsers, sometimes they 
don't get any answer. By debugging the server I realized that in such a 
case the OnPostDocument event is never triggered.



Do you have a reproductible case ?


No and that's my main problem. I tested this morning, it was awful (like 
25% of connections lost, on two different PCs. But now I'm trying 
again and it works better (I didn't change anything to the program since 
this morning, but now I only get very few connections loss).
Also, this morning I talked about the OnPostDocument event because at 
that time, nearly only POST commands had a problem. Now the post 
commands work totally fine, and the few errors concern basic GET commands.



Does it occurs with the sample WebServ delivered with ICS ?
Well it seems it doesn't (at least I didn't experienced the problem 
yet), which is surprising because my program is quite identical to the 
demo (I mean, I implemented some functions but nothing that directly 
change the way THttpServer works).




--
[EMAIL PROTECTED]
http://www.overbyte.be


- Original Message - 
From: Christophe [EMAIL PROTECTED]

To: twsocket@elists.org
Sent: Monday, June 20, 2005 4:01 AM
Subject: [twsocket] No response problem [THttpServer - TCustomLineWSocket]




Hi,

First of all, I'd like to apologize if my question is inapropriate, it 
is the first time I am using a mailing list (I usually use php based 
forums for development issues).


I searched a lot about the following problem, but I still don't have a 
clue of what's happening:


I have been developping few applications that use the THttpServer 
component. I noticed that sometimes (randomly), the server gives no 
answer to clients.
When users clicks links or post forms in their browsers, sometimes they 
don't get any answer. By debugging the server I realized that in such a 
case the OnPostDocument event is never triggered.


I checked the call stack at that time, and it seems the problem is in 
TCustomLineWSocket.TriggerDataAvailable (Unit WSocket). At the beginning 
of this function there is the following test:

if (not FLineMode) or (Length(FLineEnd) = 0) or (FSocksState  socksData)
then begin
  Result := inherited TriggerDataAvailable(Error);
  Exit;
end;

I placed breakpoints and I am pretty sure that if FLineMode is false, 
then there is no problem (the component will continue and send back data 
to the client).
If FLineMode is false, the component will stop here (after the Exit), 
and will never send anything back to the client browsers (they wait, 
and, after a while, they fail because of a timeout).


It brings 2 questions:
- For the same link (GET) or form (POST), why does sometimes FlineMode 
is true and sometimes false ?
- How to force FLineMode to be true, or more generally how to solve such 
a problem. (I tried to do a (Client as THTTPConnection).LineMode:=true 
in the OnClientConnect event but it doesn't change a thing).


PS: It is the first time I checked ICS source, so my analysis of the 
problem is maybe totally wrong.
PS2: I tested this on two different PCs with WindowsXP (no firewall, no 
antivirus) on a LAN. I re-downloaded ICS today to be sure, but the 
problem is still there.


Thank you,
Christophe

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be







--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] No response problem [THttpServer - TCustomLineWSocket]

2005-06-20 Thread Francois Piette
  Does it occurs with the sample WebServ delivered with ICS ?

 Well it seems it doesn't (at least I didn't experienced the problem
 yet), which is surprising because my program is quite identical to the
 demo (I mean, I implemented some functions but nothing that directly
 change the way THttpServer works).

It is likely that you introduced something wrong. Or failed to follow some 
programming rule.

One important thing: never call the message pump, directly or indirectly from 
one of the ICS
component event. You would get all kind of strange results. Be aware that some 
VCL internally call
the message pump, like ShowMessage.

--
[EMAIL PROTECTED]
http://www.overbyte.be


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


RE: [twsocket] No response problem [THttpServer - TCustomLineWSocket]

2005-06-20 Thread Bjørnar Nielsen

 Yes, as I explained in my last mail, when a user makes a 
 request (GET or 
 POST or HEAD or whatever), the server get it, and start to analyze it 
 but stops inside TCustomLineWSocket.TriggerDataAvailable.

Ok, I missed that part, my previos message does not explain your problem.

In PostedData-event, be sure to call PostedDataReceived on the
client-connection (linemode is set to true and FState is set to hcRequest).
This will enable the client to receive more requests on same connection (if
http1.1 and keepalive).

It would be interesting to se if the lost requests is happening on newly
created connections, or maybe only on connections that are used a second
time (many requests on same connection, http1.1 and keepalive).


Regards Bjørnar



--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] No response problem [THttpServer - TCustomLineWSocket]

2005-06-19 Thread Christophe

Hi,

First of all, I'd like to apologize if my question is inapropriate, it 
is the first time I am using a mailing list (I usually use php based 
forums for development issues).


I searched a lot about the following problem, but I still don't have a 
clue of what's happening:


I have been developping few applications that use the THttpServer 
component. I noticed that sometimes (randomly), the server gives no 
answer to clients.
When users clicks links or post forms in their browsers, sometimes they 
don't get any answer. By debugging the server I realized that in such a 
case the OnPostDocument event is never triggered.


I checked the call stack at that time, and it seems the problem is in 
TCustomLineWSocket.TriggerDataAvailable (Unit WSocket). At the beginning 
of this function there is the following test:

if (not FLineMode) or (Length(FLineEnd) = 0) or (FSocksState  socksData)
then begin
  Result := inherited TriggerDataAvailable(Error);
  Exit;
end;

I placed breakpoints and I am pretty sure that if FLineMode is false, 
then there is no problem (the component will continue and send back data 
to the client).
If FLineMode is false, the component will stop here (after the Exit), 
and will never send anything back to the client browsers (they wait, 
and, after a while, they fail because of a timeout).


It brings 2 questions:
- For the same link (GET) or form (POST), why does sometimes FlineMode 
is true and sometimes false ?
- How to force FLineMode to be true, or more generally how to solve such 
a problem. (I tried to do a (Client as THTTPConnection).LineMode:=true 
in the OnClientConnect event but it doesn't change a thing).


PS: It is the first time I checked ICS source, so my analysis of the 
problem is maybe totally wrong.
PS2: I tested this on two different PCs with WindowsXP (no firewall, no 
antivirus) on a LAN. I re-downloaded ICS today to be sure, but the 
problem is still there.


Thank you,
Christophe

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be