Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receiving data sent from AIR app in node.js server running on Heroku

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?

like image 342
deloki Avatar asked Nov 13 '22 03:11

deloki


1 Answers

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.

like image 168
GV3 Avatar answered Nov 14 '22 23:11

GV3