I am trying to receive data sent from my client adobe air application in node.js server running on Heroku, but with no success.
This is how i am sending the data:
var loader : URLLoader = new URLLoader();
var request : URLRequest = new URLRequest("http://127.0.0.1:5000");
request.method = URLRequestMethod.GET;
loader.dataFormat = URLLoaderDataFormat.TEXT;
var variables:URLVariables = new URLVariables();
variables.data = 'this is data';
request.data = variables;
loader.addEventListener(Event.COMPLETE, onRestaurantObjectLoadComplete);
loader.load(request);
And my Node.js code for receiving requests :
app.get('/',function (request, res) {
console.log("received request data" + request.data );
});
app.listen(port, function() {
console.log("Listening on " + port);
});
The requests come to the server, and i am able to send the answer to the client, but data is always undefined.
Also, if i try to send data using POST method i get a Stream error in AIR application.
What would be the correct way of sending data to node.js server from AIR application?
EDIT: I managed to make it work locally, but when i upload it to heroku, it doesnt work. I am sending the request to http://: (same as i did locally but myHerokuApp.com was localhost) and i keep getting a stream error. What would have to be the correct URL to send requests to?
It seems it only does not work on the Simulator, once on testing on a real device it will work with the URL given by Heroku.
Still don't know how to make it work on the Simulator though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With