I am trying to use integrations to send data from the Particle Cloud to a python CGI script that I have running on a Digital Ocean server. The CGI script then populates a PostgreSQL database with the data from the Particle Boron. The overall system generally works as I have other devices that use the Iridium RockBlock modems and they are communicating with the server and sending data to the database.
Unfortunately, I can't get the Particle Boron to work. I get the following error message: ETIMEDOUT when events are published and sent to the webhook integration, which seems to be related to waiting 20 seconds and not getting a response from the server. The server is not that busy, so it must be something else.
The arduino code loaded on the Particle Boron includes the following event:
Particle.publish("waterTempC", String(waterTempC), PRIVATE);
The events do appear in the console in my browser, so the arduino code seems OK.
Then my webhook integration is set up as follows:
Name > TempToDB
Event Name > waterTempC
Full URL > http://myServerIPaddress/cgi_v4_boron2.py
Request Type > POST
Request Format > Web Form
Device > Temp1
Form >
{"event": "{{{PARTICLE_EVENT_NAME}}}",
"data": "{{{PARTICLE_EVENT_VALUE}}}",
"coreid": "{{{PARTICLE_DEVICE_ID}}}",
"published_at": "{{{PARTICLE_PUBLISHED_AT}}}"}
Headers
{"Content-Type": "application/x-www-form-urlencoded"}
Enforce SSL > No
My python CGI script looks like this (I do not include the database connection in this post as it is sort of irrelevant as I am not getting a response from the server at all):
import cgi
import cgitb
cgitb.enable()
form = cgi.FieldStorage()
data = form["data"].value
coreid = form["coreid "].value
published_at = form["published_at "].value
print("Content-Type: x-www-form-urlencoded\r\n\r\n")
print("OK")
And, I've added what I think is the IP address of the Particle Cloud to my firewall exemptions:
54.208.229.0/24
The CGI script DOES work when I force it to run with dummy data:
So, in conclusion, I think the problem is either:
1 - I have the wrong IP address / Subnet Mask for the Particle Cloud
54.208.229.0/24
2 - I am not properly sending the response in my CGI script
print("Content-Type: x-www-form-urlencoded\r\n\r\n")
print("OK")
3 - I am not understanding how the webhook is formated in the POST call
** http://myServerIPaddress/cgi_v4_boron2.py?data=21.187500&published_at=2023-09-11T19:04:48.115Z&coreid=examplexample**
Or maybe it is all three issues! Thanks in advance for any insights!