TCP Client Heroku app config

Hey,

I’m trying to connect my :spark: with my Heroku App with a TCP Client, but there is no way to do it.
Has anyone tried to connect to a heroku app?

My configuration is this:

char server[] = “http://my-nodejs-app.herokuapp.com”;
if (client.connect(server, 80))
{
Serial.println(“connected”);
client.println(“GET /iniciar?var1=cts&var2=opp HTTP/1.1”);
client.println(“Host: my-nodejs-app.herokuapp.com”);
client.println(“User-Agent: spark.core-wifi”);
client.println(“Connection: close”);
client.println();
}
else
{
Serial.println(“connection failed”);
}
}

Any ideas?

Ty and remove the protocol from the server[]

server[] =“my-nodejs-app.herokuapp.com

1 Like

Try throwing a few second delay after your last client.println(), and then a client.flush(); and client.stop();

Worked when I was playing with tweets!

Thanks!
David

The page here: http://docs.spark.io/#/ mentions an example of deploying a Heroku app. Any ETA on that example?

Thanks,
Paul

I’ve got a Heroku Post working. The key for me was putting \r\n in each println … I’ll post what worked for me later today.

1 Like

This works with the Adafruit C3K ... Give it a try....

Adafruit_CC3000_Client www = cc3000.connectTCP(ip, portNum); // python endpoint on port x // heroku port 80
if (www.connected()) {
Serial.println(F("Write Python end point..."));

www.fastrprint(F("POST /post HTTP/1.1\r\n"));
www.fastrprint(F("Host: project.herokuapp.com\r\n"));
www.fastrprint(F("Content-Type: application/x-www-form-urlencoded\r\n"));
www.fastrprint(F("Connection: close\r\n"));
www.fastrprint(F("Content-Length: "));
www.fastrprint(payloadlen);
www.fastrprint(F("\r\n\r\n"));
www.fastrprint(PostData);
www.fastrprint(F("\r\n\r\n"));