Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread Problem using Chrome
Wed, Nov 19 2014 6:19 PMPermanent Link

Jim Gallagher

I'm still evaluating EWB, and I set up the simple Delphi time Webserver, with an EWB client (from the binaries forum):

http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_binaries&msg=8&page=1

This works great from within the EWB gui, and also works great when I deploy the EWB app and run it under IE with the standalone EWB server.

However, when I run the same app with Chrome, the browser swallows the response, and I just get "Response=".  I run the Delphi server under the debugger and can see the response being set correctly.  

Is there some configuration I need to do to make Chrome happy?

-Jim
Thu, Nov 20 2014 4:10 AMPermanent Link

Matthew Jones

Jim Gallagher wrote:

> I'm still evaluating EWB, and I set up the simple Delphi time
> Webserver, with an EWB client (from the binaries forum):
>
>
http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_binaries&msg=8&page=1
>
> This works great from within the EWB gui, and also works great when I
> deploy the EWB app and run it under IE with the standalone EWB server.
>
> However, when I run the same app with Chrome, the browser swallows
> the response, and I just get "Response=".  I run the Delphi server
> under the debugger and can see the response being set correctly.
>
> Is there some configuration I need to do to make Chrome happy?

This is of course a third party demo from nearly two years ago, so it
is probable that some detail changed. However, Chrome is excellent for
working with EWB as it has good debugging tools. Hit F12, and you can
then see all the traffic, and all the code. You can even put
breakpoints in places, and thus see exactly what is in the variables. I
find it handy to put a "DummyVar = 'HelloMum';" line in my code, so I
can then search for "HelloMum" in the javascript, and then I can see
the matching code and breakpoint it appropriately.

By digging in, you will understand it all a lot better, and see the
full power you have available.


--

Matthew Jones
Thu, Nov 20 2014 2:06 PMPermanent Link

Jim Gallagher

"Matthew Jones" wrote:

>By digging in, you will understand it all a lot better, and see the
>full power you have available.

Thanks Matthew.  My default position is "user error" when trying new software.  I have spent quite a bit of time trying to get this to work, and I have to say that debugging into the code is not going to be helpful.  This is the entire WB object pascal implementation:

procedure TForm1.Button1Click(Sender: TObject);
begin
 ServerRequest1.URL := 'http://localhost:81/Time';
 ServerRequest1.Method := rmGet;
 ServerRequest1.Execute;
end;

procedure TForm1.ServerRequest1Complete(Request: TServerRequest);
begin
 Memo1.Lines.Clear;
 Memo1.Lines.Add('Response='+Request.ResponseContent.text);
end;

This generates 600k of javascript, but the translation of the above code is:

ufrmtestserver_tform1.$p.tform1_button1click = function(sender)
{
  var $t = this;
  $t.tform1_serverrequest1.tserverrequest_furl = "http:\/\/localhost:81\/Time";
  $t.tform1_serverrequest1.tserverrequest_fmethod = webhttp_rmget;
  $t.tform1_serverrequest1.execute();
};

ufrmtestserver_tform1.$p.tform1_serverrequest1complete = function(request)
{
  var $t = this;
  $t.tform1_memo1.tmemo_flines.clear();
  $t.tform1_memo1.tmemo_flines.add("Response=" + request.tserverrequest_fresponsecontent.gettext());
};

This code works in the ide.  With the standalone WB server it also works in IE, but does not work (for me) in Chrome or in FireFox.  I just get "Response=" without the response text.  

I'm still convinced that I'm doing something wrong, but I cannot see what.

I realize that this is an old demo but I recompiled the Delphi server part, and the javascript is generated on the fly.  It couldn't be a simpler program.  I liked the demo for that reason.  If talking to a web service is not a suitable use for WB, I will investigate the module creation.  I would like to move as much functionality to the server as possible, but frankly I like the idea of using a web service, since it seems cleaner.

-Jim
Thu, Nov 20 2014 2:52 PMPermanent Link

Raul

Team Elevate Team Elevate

On 11/19/2014 6:19 PM, Jim Gallagher wrote:
> However, when I run the same app with Chrome, the browser swallows the response, and I just get "Response=".  I run the Delphi server under the debugger and can see the response being set correctly.
>
> Is there some configuration I need to do to make Chrome happy?

You're probably running into cross-origin resource sharing (CORS)
problem here. Chrome is quite strict on this (while IE is IMHO too
lenient) - issue has nothing to do with EWB but with the sample time
server you're using.

I'm guessing you're loading your app either from local drive direct
(open html file) or from EWB web server or EWB IDE using URL ?

In all those cases that is different resources than sample server on
port 81 (or any other port).

To fix the delphi server add this to part wehre time is returned :

    AResponseInfo.CustomHeaders.Add('Access-Control-Allow-Origin: *');

so the 2 lines in the IF should look like this :

    AResponseInfo.CustomHeaders.Add('Access-Control-Allow-Origin: *');
    AResponseInfo.ContentText := 'Time Is: ' + DateTimeToStr(Now);

and it should fix it.


For more reading look for "Enable Cross-Origin Resource Sharing" in here
:
http://www.elevatesoft.com/manual?action=viewtopic&id=ewb1&topic=Configuring_Server



Raul
Thu, Nov 20 2014 3:18 PMPermanent Link

Jim Gallagher

Raul wrote:

>so the 2 lines in the IF should look like this :

>     AResponseInfo.CustomHeaders.Add('Access-Control-Allow-Origin: *');
>     AResponseInfo.ContentText := 'Time Is: ' + DateTimeToStr(Now);

>and it should fix it.

>For more reading look for "Enable Cross-Origin Resource Sharing" in here
:
> http://www.elevatesoft.com/manual?action=viewtopic&id=ewb1&topic=Configuring_Server

Thanks Raul, I truly appreciate your help.  Your recommendation did indeed fix the issue in  FireFox, but not Chrome.  You've certainly identified the issue, though, and I will read up on this and see if I can change things around to get it to work.  

Thanks again,

-Jim
Thu, Nov 20 2014 3:33 PMPermanent Link

Raul

Team Elevate Team Elevate

On 11/20/2014 3:18 PM, Jim Gallagher wrote:
> Thanks Raul, I truly appreciate your help.  Your recommendation did indeed fix the issue in  FireFox, but not Chrome.  You've certainly identified the issue, though, and I will read up on this and see if I can change things around to get it to work.

How are you loading the app? If you're opening it straight from file
system html file then that will likely not work in Chrome at all.

I just tried it here (using the IDE web server to serve up the app with
a URL) and sample app works fine in Chrome for me (ver 38.0.2125.111 m
and 39.0.2171.65 m as chrome wanted to update itself ) as well as
Firefox (33.1.1) not to mention embedded IE in EWB itself.

Raul

Thu, Nov 20 2014 4:02 PMPermanent Link

Jim Gallagher

Raul wrote:

>How are you loading the app? If you're opening it straight from file
>system html file then that will likely not work in Chrome at all.

I'm using the standalone WB server (not as a service) and I set the content folder to my deploy directory.  I enter http://localhost:8081/testserver.html in my browser.  I also tried entering the ide URL in Chrome (same as above, but with port 8080), with the same results.

I've been using Chrome 38.0.2125.111 m, but I just updated to 39 too, but it didn't change anything.

Since it's working for you, I'm pretty sure I've got some little thing wrong.  I'll try deploying on my test server since that's more of a real-world kind of test.

Again, thanks.  I would have been staring at code for another week without your help.

-Jim
Fri, Nov 21 2014 5:47 AMPermanent Link

Matthew Jones

Jim Gallagher wrote:

> I'm using the standalone WB server (not as a service) and I set the
> content folder to my deploy directory.  I enter
> http://localhost:8081/testserver.html in my browser.  I also tried
> entering the ide URL in Chrome (same as above, but with port 8080),
> with the same results.

Raul got it - the key is that the code says it is connecting to port
81, and so that's where you must get the HTML from. Or change the code
to match the server.

--

Matthew Jones
Fri, Nov 21 2014 8:25 AMPermanent Link

Raul

Team Elevate Team Elevate

On 11/20/2014 4:02 PM, Jim Gallagher wrote:
> I'm using the standalone WB server (not as a service) and I set the content folder to my deploy directory.  I enter http://localhost:8081/testserver.html in my browser.  I also tried entering the ide URL in Chrome (same as above, but with port 8080), with the same results.
> Since it's working for you, I'm pretty sure I've got some little thing wrong.  I'll try deploying on my test server since that's more of a real-world kind of test.

It should work though so still curious what is going on on your side as
the config is very straightforward.

I tried the exact setup here - ewb web server on port 8081 with content
folder set for ewb app deploy folder and and delphi sample time server
running on port 81 - it works in chrome for me.

Any chance your chrome has either proxy settings or a plugin or
anti-virus or such installed that might interfere ?

Just the time part works - if you want the server to also respond with
hello then the CORS header in delphi code should always be returned.

Raul
Fri, Nov 21 2014 11:20 AMPermanent Link

Jim Gallagher

Raul wrote:

>I tried the exact setup here - ewb web server on port 8081 with content
>folder set for ewb app deploy folder and and delphi sample time server
>running on port 81 - it works in chrome for me.

It works for me now, too.  In trying to fix the problem I tried dozens of things, including changing the color of my socks, so when I applied your fix, it was in a toxic development environment.  Last night I reset everything back to the beginning, and it works as expected.

Well, not as expected.  The whole reason I was running it outside of the ide was to test how it worked.  I thought that perhaps the WB server was doing the web service call under the covers and returning, over http, the result to the client.  I was reading tea leaves in this, from the manual:

"The TServerRequest compoenent is used to make a dynamic HTTP request to the web server from which the application was loaded."

I see that it is the browser client that is making the request, and I can understand why this would be a security problem.

I don't mean this as a criticism of the way it works - I'm just trying to get my bearings. I'm finding Web Builder to be pretty amazing.

-Jim
Page 1 of 2Next Page »
Jump to Page:  1 2
Image