SparkFun + imp - How to push data to my localhost

I have phant installed in my local machine for testing at http://127.0.0.1:8080/

And I have tried to send my data from imp ide to http://127.0.0.1:8080/ but it does not seem to work at all.

I can see that imp is sending data in the log:

2016-06-19 19:52:49 UTC+8 [Agent] Sending particles=0 2016-06-19 19:52:50 UTC+8 [Agent] Phant response: 2016-06-19 19:53:17 UTC+8 [Agent] Sending particles=0 2016-06-19 19:53:17 UTC+8 [Device] Sending Data! 2016-06-19 19:53:17 UTC+8 [Device] particles: 0 2016-06-19 19:53:18 UTC+8 [Agent] Phant response: 2016-06-19 19:53:46 UTC+8 [Device] Sending Data! 2016-06-19 19:53:46 UTC+8 [Device] particles: 0 2016-06-19 19:53:46 UTC+8 [Agent] Sending particles=0 2016-06-19 19:53:47 UTC+8 [Agent] Phant response:

But there is no data receiving on http://127.0.0.1:8080/

Below is my code in imp ide:

///////////////// // Phant Stuff // ///////////////// local publicKey = "xxx"; // Your Phant public key local privateKey = "xxx"; // The Phant private key local phantServer = "127.0.0.1:8080"; // Your Phant server, base URL, no HTTP

/////////////////////
// postData Action //
/////////////////////
// When the agent receives a “postData” string from the device, use the
// dataString string to construct a HTTP POST, and send it to the server.
device.on(“postData”, function(dataString) {

server.log("Sending " + dataString); // Print a debug message

// Construct the base URL: https://data.sparkfun.com/input/PUBLIC_KEY:
local phantURL = "http://" +  phantServer + "/input/" + publicKey;
// Construct the headers: e.g. "Phant-Priave-Key: PRIVATE_KEY"
local phantHeaders = {"Phant-Private-Key": privateKey, "connection": "close"};
// Send the POST to phantURL, with phantHeaders, and dataString data.
local request = http.post(phantURL, phantHeaders, dataString);

// Get the response from the server, and send it out the debug window:
local response = request.sendsync();
server.log("Phant response: " + response.body);

});

Any ideas why and what I have missed?

I guess I’m not sure about the “local server” part. How does your server receive it? Do you use PHP, or ?? I assume your server is connected to the internet at all times.

Use the pre-made Imp Library as shown here:
https://electricimp.com/docs/libraries/webservices/phant/

Your agent is running in the electric imp cloud on Amazon. It won’t be able to see your local address. If you are determined to run it locally, you’ll need to open up access to the Internet via a gateway, so your computer has an IP that’s visible to the outside world.

Also, please don’t start multiple threads about the same problem!

Peter