httpsocket works on debug but not on build - get content from localhost

Hello,

I have a HTTPSocket in a web app that points to localhost (on the user’s computer) to retrieve data from a small app that acts as a web server.

The HTTPSocket, subclassed as ‘DataSocket’, is encapsulated in a class, structured like this:

DataSocket
- Event Definitions
- Completed
- Failed

  • Event Handlers
    • Error
    • PageReceived
  • Methods
    • Collect
  • Properties
    • myFIR
    • loc_extFIR

Inside the method ‘Collect’, that takes ‘ext_FIR’ as a string parameter, there is this code:

loc_extFIR = ext_FIR

If Self <> Nil Then
  Self.Get("http://localhost:9000/api/public/v1/captura/Capturar/1")
  
End If

On ‘PageReceived’ ‘content’ is treated, result is stored in ‘myFIR’ property and ‘Completed’ event is raised.

Can someone point me out why does works on debug but not on a deployed app? It also works if the address is pasted directly to a browser or rembedded in php script on the web…

What I did so far:

  • Checked Norton Security to set port 9000 open;
  • Tried to point HTTPSocket to the web address with the php script pointing to localhost.

Any help and ideas are appreciated!

No error event called?

I assume this is the same situation with your other post - so I am posting here the same response for the record.

[quote]Error 103 is a name resolution error
https://documentation.xojo.com/index.php/SocketCore.LastErrorCode

So you may need to change up the URL of your GET request on linux for some reason. Sometimes ‘localhost’ vs ‘127.0.0.1’ produces different results (sometimes localhost is treated as a socket connection - or IPv6, which can cause problems) - did you try putting in the loopback ip address above?[/quote]

Instead of communicating through localhost, it should possible for your two apps to communicate through an IPCSocket instead. At least, if you created both the web and helper app.

[quote=387048:@Leonidas Brasileiro]Hello,
I have a HTTPSocket in a web app that points to localhost (on the user’s computer) to retrieve data from a small app that acts as a web server.
![/quote]
You do understand that “localhost” refers to the machine where the web app is actually running, right? When you debug, everything is running on your local machine. The web app, the browser and the other app. When you deploy the app, the HTTPSocket is actually on the server where the web app is, and localhost points to that machine, not where the browser is.

[quote=387048:@Leonidas Brasileiro]If Self <> Nil Then
Self.Get(“http://localhost:9000/api/public/v1/captura/Capturar/1”)

End If[/quote]
This URL will alway point to your Webserver, als it runs on the server not the client.
To do that you have to use something like that:

  Self.Get("http://<client-ip>:9000/api/public/v1/captura/Capturar/1")

[quote=387173:@Marius Dieter Noetzel]This URL will alway point to your Webserver, als it runs on the server not the client.
To do that you have to use something like that:

  Self.Get("http://<client-ip>:9000/api/public/v1/captura/Capturar/1")

And hope that the firewall and NAT cooperate.

And that the local App not only listens on localhost, would allow requests from outside, etc.
But that is the next part of the game :wink:
To try that, use fetch / wget / curl on the server and try to receive the url from one of your clients. If that works, the app should work…

@Greg O’Lone

[quote]
You do understand that “localhost” refers to the machine where the web app is actually running, right? When you debug, everything is running on your local machine. The web app, the browser and the other app. When you deploy the app, the HTTPSocket is actually on the server where the web app is, and localhost points to that machine, not where the browser is.[/quote]

I suspected that…

I’ll try something around @Marius Dieter Noetzel 's suggestion.

Thanks a lot to @John Joyce , whose first answer (on the other post ) pointed me to the right direction.

As the helper app is a small C# program supplied by the biometric reader manufacturer, which I have the code, I might be able to adapt it to what is needed.

Just as a side note, writing code on Visual Studio C# is somewhat painful. I’m seriously considering rewriting it on Xojo. The only thing preventing me to do that (other than time) is that with Xojo I’ll have to use dll ‘ole32.dll’ that has proven to be problematic on some old computers running Windows 7. C# accesses the biometric driver directly.

I’ll make modifications and run some tests and report back here the solution.

Thansk a lot!