[AC-2572] How to get a http request working and the http.createServer in standard nodes of the Node.ACS space?
GitHub Issue | n/a |
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Needs more info |
Resolution Date | 2013-10-15T22:51:45.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Appcelerator CLI |
Labels | Node.ACS |
Reporter | Jörgen Buder |
Assignee | Seth Toda |
Created | 2013-10-11T21:24:51.000+0000 |
Updated | 2016-03-08T07:41:38.000+0000 |
Description
Hi PK
I have started to create what I try to sell, i.e. a Node.ACS custom connector to a web API that I want to host in the cloud in the MobileFirst way.
I have made a nodejs server, handling http requests to web API with the "request" module, I have used the built in http module to handle incoming GET requests.
In the documentation it says that I can upload a standard nodejs module to the cloud, but it does not seem to work well.
I am sure I am doing this wrong, so this is not a bug, even so I have scraped gut hub, your docs, google and other remote places and cannot find any example of how to receive http requests in any other way then through the config.json filtering, this is not standard nodejs. I also want to be able to request data from a web service with http requests, I use the "request" module for this.
It seems I can start the module in the cloud from studio, I can see my code runs, but I get errors and above all I am not sure how to handle the https uri that I get from the publish script in pespective to the http.createServer function, in which I state the port and ip number, in my case I use the localhost, which I suppose should be different in the cloud, but what do I set it to? I want users to make GET requests to my URL and how do I call the createServer function?
From the client side? Should I use some key in tiapp.xml? It says so in the dialog, out the URI in the tiapp.xml? Ok, where? Really I don+t see it, there is a cloud url, but does that one not have to be the set url so thaht I can call the ACS cloud as normal?
The whole idea around the mobile first shift is to host your custom backends in the cloud so that you can manage the data and reach it in a unison way, like SAP or Sharepoint, now with my custom connector I need to have those two fundamental features working and I would like to use my already working script in node.ACS as the doc says it should be possible.
In other words I can´t find docs describing these things more in detail, and I cannot find examples, can you please help me or find someone that can?
I will attach the code used in the server side node. It works well local of course...
the example.js code can be run with node in terminal.
I tool that code and put it into the node.ACS project and disbaled the MVC framework, added dependancy and published to cloud, it runs but do not ask for data from web API, and I do not know how to call GET on the uri provided..
I know this might seem like basic questions, in the Mobile App I can handle this but in node, ....
I attach the node.ACS as well for reference..
Any comment or hint before weekend would be great as I will work with it.
thanks
Attachments
Hello, this looks more like a question for the Q&A Site than a bug. Please go to it at: http://developer.appcelerator.com/questions/newest if you feel that this is a bug, please follow the guide for bug reporting: https://wiki.appcelerator.org/display/tis/Reporting+Bugs+or+Requesting+Features#ReportingBugsorRequestingFeatures-BugSubmissionSteps Best, Mauro
Hello Jörgen, I took the project that you uploaded in a zip and was not able to reproduce your errors on the cloud. Navigating to the URL that studio outputs provides a functional JSON feed. I was able to access the data from a mobile app with a Ti.Network.HTTPClient. Here is what that code looked like:
More info on the HTTPClient can be found here... http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Network.HTTPClient Hopefully this sheds some light on the issue. - Seth