 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Tim Robbins Guest
|
Posted: Mon Dec 05, 2005 12:00 am Post subject: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
I found some strange behaviors in trying to set up some preliminary
performance tests. In particular, I wanted to hammer a minor server
with automated local requests, either on the same machine or on the
local network. To my great surprise using Synapse clients to access a
Synapse server did not work (at least here and now...), although the
few other combinations I tried DID work (Internet Explorer (IE) to
Synapse; Indy to Synapse; Synapse to Indy...).
Even stranger: while waiting for a simple HttpGetText() to complete
(which just hangs until the timeout, either on the same machine or from
another on the local net)... if you SHUT DOWN the httpserv demo while
the client's still waiting, the client immediately completes, reacting
to the shutdown, instead of waiting for the timeout.
BTW, if HttpGetText() (and HTTPMethod() etc.) time out, the routines
STILL return reporting a SUCCESSFUL result value. This doesn't seem
right.
I'd love to hear what I'm doing wrong!
|
|
| Back to top |
|
 |
theo Guest
|
Posted: Mon Dec 05, 2005 10:52 am Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
| Quote: |
I'd love to hear what I'm doing wrong!
|
First, you're asking in the wrong forum.
Ask or search for a solution in the Synapse mailinglist. See here for
instructions:
http://sourceforge.net/mail/?group_id=125224
|
|
| Back to top |
|
 |
Tim Robbins Guest
|
Posted: Mon Dec 05, 2005 3:05 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
theo wrote:
| Quote: | Ask or search for a solution in the Synapse mailinglist.
|
Sorry. I'm not allowed to use mailing lists.
At this point, the right solution might be to go to a commercial
library anyway.
|
|
| Back to top |
|
 |
Tim Robbins Guest
|
Posted: Mon Dec 05, 2005 6:37 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
Theo,
I went through the SourceForge Synapse email archive, and didn't find
anything pertinent. Since there is some Synapse discussion in this
newsgroup (and you and Tony constantly recommend Synapse), I'd like to
continue this topic here, if anyone is willing.
I'd be very interested if anyone else here using Synapse has seen the
same behavior (that the http client can't communicate with the http
server).
The *extremely* simple and quickly set up test that I used was to run
the (fixed) httpserv program and then run another simplistic program
(either on the same or another computer) that just tries to get the
most basic response.
Basically: (substituting another address where appropriate)
success := HttpGetText('127.0.0.1', StringList);
As stated in the first posting in this thread: that call always fails
either by timing out (unless the server is shut down while waiting) or
recently somewhat faster, but though it fails it reports success. All
other means of communicating with the server (IE, Indy, telnet...) work!
That's very odd... and raises a lot of concern...
Using (Synapse client) HttpGetText() to talk with the Indy server
demo... works!
A one-liner Indy client easily "talks" with the Synapse server demo:
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.text := IdHTTP1.Get('127.0.0.1');
end;
BUT, no joy on the Synapse to Synapse conversation!!
|
|
| Back to top |
|
 |
theo Guest
|
Posted: Mon Dec 05, 2005 8:00 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
Hmm, sounds strange indeed.
To put some light in it, you should try to get the Socket Status event
at least in the client.
like:
fHTTP.Sock.OnStatus:=Status; (See Below)
This will show you where it hangs:
you can print the state(s) with the help of this
const SocketReasonStrings: array[0..13] of string = ('ResolvingBegin',
'ResolvingEnd', 'SocketCreate', 'SocketClose',
'Bind', 'Connect', 'CanRead', 'CanWrite', 'Listen',
'Accept', 'ReadCount', 'WriteCount', 'Wait', 'Error');
procedure TMyHTTP.Status(Sender: TObject; Reason: THookSocketReason;
const Value: string);
begin
writeln(SocketReasonStrings[Ord(Reason)]+': '+Value);
end;
//untested
|
|
| Back to top |
|
 |
theo Guest
|
Posted: Mon Dec 05, 2005 8:07 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
| Quote: |
As stated in the first posting in this thread: that call always fails
either by timing out (unless the server is shut down while waiting) or
recently somewhat faster, but though it fails it reports success. All
other means of communicating with the server (IE, Indy, telnet...) work!
|
I have no idea because I don't see the code, but this could also be a
simple protocol problem like the client or server waiting for some CRLF
sequence before disconnect.
|
|
| Back to top |
|
 |
Tim Robbins Guest
|
Posted: Mon Dec 05, 2005 8:55 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
theo wrote:
| Quote: | To put some light in it, you should try to get the Socket Status
event at least in the client.
|
OK. Did that. Unfortunately, from my newcomer's point of view, this
doesn't offer any more information than what I'd found tracing
through... but it offers the information in a much more digestible form
<G>! The GET "successfully" writes to the socket but doesn't receive
anything in turn.
Here's what a successful GET shows (Synapse hitting INDY server demo):
SocketClose:
ResolvingBegin: 127.0.0.1:80
ResolvingEnd: 127.0.0.1:80
SocketCreate: IPv4
Connect: 127.0.0.1:80
WriteCount: 101
ReadCount: 202
SocketClose:
SocketClose:
Here's what a failed Synapse client to Synapse server reports:
SocketClose:
ResolvingBegin: 127.0.0.1:80
ResolvingEnd: 127.0.0.1:80
SocketCreate: IPv4
Connect: 127.0.0.1:80
WriteCount: 101
***** LONG PAUSE HERE FOR TIMEOUT *****
Error: 10060,Connection timed out
Error: 10060,Connection timed out
CanRead:
Error: 10054,Connection reset by peer
SocketClose:
SocketClose:
|
|
| Back to top |
|
 |
Tim Robbins Guest
|
Posted: Mon Dec 05, 2005 9:20 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
Ben,
Oops. I hit send before saying:
Thank you!
|
|
| Back to top |
|
 |
Tim Robbins Guest
|
Posted: Mon Dec 05, 2005 9:25 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
Theo,
What are the odds that these fixes will be folded into the library's
code? Are you and Ben contributors (committers)?
|
|
| Back to top |
|
 |
Ben Hochstrasser Guest
|
Posted: Mon Dec 05, 2005 10:01 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
theo wrote:
| Quote: | I have no idea because I don't see the code, but this could also be a
simple protocol problem like the client or server waiting for some CRLF
sequence before disconnect.
|
Ah, in httpsend.pas, lines 369ff, change
if status100 then
FHeaders.Insert(0, 'Expect: 100-continue');
FHeaders.Insert(0, 'Content-Length: ' + IntToStr(FDocument.Size));
if Sending then
begin
// FHeaders.Insert(0, 'Content-Length: ' + IntToStr(FDocument.Size));
if FMimeType <> '' then
FHeaders.Insert(0, 'Content-Type: ' + FMimeType);
end;
to
if status100 then
FHeaders.Insert(0, 'Expect: 100-continue');
// FHeaders.Insert(0, 'Content-Length: ' + IntToStr(FDocument.Size));
if Sending then
begin
FHeaders.Insert(0, 'Content-Length: ' + IntToStr(FDocument.Size));
if FMimeType <> '' then
FHeaders.Insert(0, 'Content-Type: ' + FMimeType);
end;
ie even with an empty document to send (eg upload) httpsend.pas sends a
"Content-Length" header; the server in turn waits for n content-length
bytes (or infinitely when it's set to zero (=unknown).
--
Ben
|
|
| Back to top |
|
 |
theo Guest
|
Posted: Mon Dec 05, 2005 10:21 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
Ben Hochstrasser schrieb:
| Quote: | theo wrote:
I have no idea because I don't see the code, but this could also be a
simple protocol problem like the client or server waiting for some CRLF
sequence before disconnect.
|
Congratulations! ;-)
I've found the problem myself now, although I've fixed it on the server
side:
procedure TTCPHttpThrd.Execute;
......
Headers.add(s);
Size := -1; // ADD THIS LINE IF CONTENT-LENGTH NOT SENT!
if Pos('CONTENT-LENGTH:', Uppercase(s)) = 1 then
Size := StrToIntDef(SeparateRight(s, ' '), -1);
|
|
| Back to top |
|
 |
Ben Hochstrasser Guest
|
Posted: Mon Dec 05, 2005 10:38 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
Tim Robbins wrote:
| Quote: | What are the odds that these fixes will be folded into the library's
code?
|
I'll open a bug report via the mailing list.
| Quote: | Are you and Ben contributors (committers)?
|
No. I'm just a long-time (and happy) user.
--
Ben
|
|
| Back to top |
|
 |
theo Guest
|
Posted: Mon Dec 05, 2005 10:39 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
Tim Robbins schrieb:
| Quote: | Theo,
What are the odds that these fixes will be folded into the library's
code? Are you and Ben contributors (committers)?
|
No, I'm not.
Rule #1: Never trust a Synapse-demo. They're sometimes outdated or just
"get you going" without being complete or bug-free.
The Synapse Library however has less bugs than Indy imho.
Synapse's advantage is (for me): less blackboxes, less bloated, and once
you know how it works, you feel like you'd understand something ;-)
Disadvantages: (The other side of the medal) It's less automated.
Example: There is no "follow redirects" in httpsend. You have to code
that by hand.
But for writing decent servers, it's better than Indy (always imho).
Why not contribute? Humm, I think I forget the problem after fixing
it.... ;-)
|
|
| Back to top |
|
 |
Ben Hochstrasser Guest
|
Posted: Mon Dec 05, 2005 10:42 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
theo wrote:
| Quote: | I've found the problem myself now, although I've fixed it on the server
side:
|
I traced the dialog with Firefox, MSIE etc, and the browsers do /not/ send
a "Content-Length:" header when there's nothing to send. A server, however,
might want to wait for some arbitrary time when it encounters a Content-
Length header entry, even if it's zero. (But most probably ignore it when
the request is "GET")
--
Ben
|
|
| Back to top |
|
 |
theo Guest
|
Posted: Mon Dec 05, 2005 10:54 pm Post subject: Re: Synapse httpserv doesn't "talk" with Synapse clients |
|
|
Hi Ben
| Quote: | A server, however,
might want to wait for some arbitrary time when it encounters a Content-
Length header entry, even if it's zero.
|
What for? Can you elaborate?
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|