Hi,

I have a local rest service (node.js) running on port 3000 on my developer machine (localhost). I would like to get my Mobile App to connect to this service, but it fails to connect.

There have been many posts around this issue, but non for platform 10 and have reviewed without success (they are also quite old so seem to refer to older environments).,So asking this to understand better/ find out what I'm missing.

Here is more detail of what I've done in Outsystems 10:

I've created REST API's, and set the address (Base URL) to https://localhost:3000

Then I have a POST entry (Rest API Method) with URL Path set to /api/login

I then open up the REST API Method (Doubleclick). Method URL is set to https://localhost:3000/api/login.

I click the TEST tab, and hit TEST button. Says 'Contacting cloud'. Then I  get the following response:

Internal Server Error.Unable to connect to the remote server

No, I gather that the environment outsystems is running this on is on a remote server in the cloud. I thought however that there is some bridge to my local environment. How can I set this up? Do I need to configure some port forwarding, or is there a firewall of sorts to open? Or does OutSystems require me to open up a public IP for dev testing (hopefully not!).


Please advise what I'm missing.The platform looks great so really want to continue playing but without access to my REST service it's a bit boring :-)


Thanks!

Gerhard

Solution

Hi Gerhard,

Your OutSystems applications run indeed not on your local machine, but on an application server. That could be on premise or in the cloud. I assume you connect Service Studio to something like gerhardoosthuizen.outsystemscloud.com? Then that's where your OutSystems web apps are running (which also shows when you open them in your browser).

localhost, by definition, is the name for the local computer, i.e. the computer that the application is running on. Every internet-connected computer in the world has a localhost. There is really no way at all for the OutSystems application server to know that you intend it to connect to your development machine, that may not even be reachable from the outside world (e.g. because it sits behind a firewall in a company network). Even if there were a "bridge" to the local environment (via VPN? anyway, there isn't), localhost would still be the server's own localhost.

So yes, if you really need your OutSystems apps (hosted in the cloud) to connect to a dev machine that's inside your office, you need to have a public IP.

Solution
I also experienced the same problem, which means that outsystems are not easy if I want to use a api rest on localhost, this is what makes me not be using outsystem to build a mobile application

rudy liu wrote:

I also experienced the same problem, which means that outsystems are not easy if I want to use a api rest on localhost, this is what makes me not be using outsystem to build a mobile application

 Hi Rudy,

You reply to a 2.5 year old post, that explains why it is not possible to connect OutSystems cloud app to your an application running on a local host. It is not an OutSystems problem. You should better ask yourself why you are running something on a local host that needs to connect to an OutSystems mobile application running in the cloud.

Regards,

Daniel



ok, sorry I did not notice the post date it has been 2.5 years, so here it is, I use an outsystem application that is already installed on the my laptop and then I try to make a mobile app using the outsystem then I try to use logic -> Rest -> Consume Rest Api, then I try to run rest api I have made it locally through visual studio and I run it, well if through postman it works fine while through this outsystem (Rest) it gets an error "unable to connect to remote server", whereas if I use the javascript programming language using the command "XMLHttpRequest ()" can work well with the output of json data and that a programmer needs to develop an application and local testing first (not in the cloud) to save time

Hi Rudy,

....and still, you keep replying in a 2.5 year old post.

It would be better to create a new thread for your problem. But he, lets do that with a future problem or question your have regarding OutSystems.

Back to your last reply.

OutSystems applications do not run on a laptop.

They either run in the cloud or on on-premise server, or did you install a complete OutSystems environment on your laptop?

Your Postman application is installed locally on your laptop and will not have problems using local host.

OutSystems Service Studio is installed locally on your laptop, but unless you have an on-premise installation of OutSystems on your laptop, OutSystems environment is running in the cloud and thereby has no means to connect to your local server unless it is publicly accessible in the cloud.

Again, this is not an OutSystems limitation. Any other application build with any language running in the cloud will not be able to access your local host.

A few final questions:

  1. Who will consume the local REST API you created in Visual Studio, because, trully it will only be accessible by applications that run locally on your computer?
  2. Are you planning to deploy this API on a internet server connected to the Internet, then you should do that first and test with that.
  3. Why, when you know how to create REST API with OutSystems, you need to create also a REST API with Visual Studio?

Regards,

Daniel.

Dear Daniel,

sorry, because I have already posted here, maybe later in the future I will open a new thread in this forum, and I get your explanation if the outsystems application must run in the cloud, ok, maybe later I will learn more, and to answer questions you as follows:

1. Who will consume the local REST API you created in Visual Studio, because, it will only be accessible by applications that run locally on your computer?

my answer :

First of all, it is used by the programmer or myself in Visual Studio for testing purposes which is used to be used for making mobile applications, then if everything is running with the Rest API application (webapi) and we will upload it to our server (on premish) which Already published next our mobile application has also been made, we will publish it to the Playstore so other users can use it


2. Are you planning to deploy this API on an internet server connected to the Internet, then you should do that first and test with that.

my answer:

Yes, the Rest Api application and the Mobile Application that we made to be used on the internet, therefore we need to have the testing itself first on the local personal computer both me and the other programmer team


3. Why, when you know how to create a REST API with OutSystems, do you need to also create a REST API with Visual Studio?

My answer:

We have our own Api Rest (Webapi) that has been created in visual studio and is already running (live) and because our Api Rest is already large and complex, it is not possible for us to re-create it or change it in Rest Api Outsystems because it might just be complicated and need time.

 That's all, Thanks

Hi Rudy,

Clear, my final advice is try publish your (non-outsystems) api for testing purpose also in cloud environment, then OutSystems will be able to connect.

Regards,

Daniel 

Hi rudy liu,

You seem to have missed the point of Kilian's answer above.

OutSystems applications are web applications. Even the mobile applications developed in OutSystems are still based in web technologies running inside a native Cordova shell on your devices. This means that any business logic running server side (and the consumed REST APIs are always called from the server-side in OutSystems) will always run on the OutSystems server, never on the developer's computer.

The consequence of this is that when you use localhost as the hostname in your REST endpoint:

  • Service Studio or Visual Studio, both running on your machine, would interpret it as "this machine" = "the developer's computer"
  • The application running on the OutSystems server, would interpret it as "this machine" = "the OutSystems server" - and it wouldn't find the endpoint there.

It's fine to still test your REST API locally on your machine, but the OutSystems server needs to be able to reach it, so you need to specify your computer's hostname or IP when you set the endpoint of the REST API on your OutSystems application. And of course, the application will only be able to call the REST API as long as the developer's computer is turned on and accessible to the OutSystems server.

Hope this further clarifies things.