-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
webhook generates empty post #186
Comments
Hi, @victorclaessen Is your message going to be big? There is a BUG in v4.0.6 that causes a large message not to be encoded as JSON. see emqx/emqx#3382 Please you can try the v4.1-alpha.2 version. It may be fixed it. |
In my case, the message payload was short (the string value "test"), so I'm not sure if the bug affects this situation. Could you possibly comment on my test strategy? Am I doing things right generally?
|
I'm sorry. My understanding of parsing POST data in PHP was wrong. EMQ is posting all the variables as json. PHP just doesn't get json data like it does HTML form data (as explained here). When I changed my webhook.php to the following, I got my json formatted data:
The data in the log file was:
I will now go on to try and figure out how to format the json data. I did not find anything about the formatting in the documentation. If I cannot get it to work, I will open a new issue. Sorry to bother you with this. |
emqx 4.0.6
I am trying to get webhooks working, but am having an issue. Perhaps I do not understand what exactly I have to do. The documentation is not sufficient for me.
I have been able to make emqx republish data on another mqtt topic using rules, but not post it to a webhook. I will explain the steps I have taken.
Using the EMQ dashboard, I make a rule with the SQL
"SELECT payload FROM "t/#"
. I then add an action handler, and select "Data to Web Server" using a previously configured resource (POST
tohttp://localhost/webhook.php
, emptyrequest header
list). I leave thePayload Template
field empty.I have the following
webhook.php
:I then post to topic
t/test
a string value oftest
. I can then see in the apache log that emqx has posted towebhook.php
. The filelog/post.log
has been made. Unfortunately, the contents of the file is the PHP representation of an empty array, i.e. the POST was empty.I was hoping for things like clientid, topic and payload to have been posted.
Can you suggest what I am doing wrong?
Thanks!
The text was updated successfully, but these errors were encountered: