GithubHelp home page GithubHelp logo

webhook generates empty post about emqx-web-hook HOT 3 CLOSED

emqx avatar emqx commented on May 22, 2024
webhook generates empty post

from emqx-web-hook.

Comments (3)

HJianBo avatar HJianBo commented on May 22, 2024

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.

from emqx-web-hook.

victorclaessen avatar victorclaessen commented on May 22, 2024

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 will try to get the alpha version. (edit) I have looked at the alpha version of the plugin, but I'm not sure how to compile it. Do you have instructions for compiling, or a binary for Debian 10/amd64?

from emqx-web-hook.

victorclaessen avatar victorclaessen commented on May 22, 2024

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:

<?php
$name=$_SERVER[UNIQUE_ID];
file_put_contents("webhooklog/post.$name.log", file_get_contents("php://input"));
print "ok";
?>

The data in the log file was:

{"username":"undefined","topic":"t/test","timestamp":1587891259502,"qos":0,"publish_received_at":1587891259502,"peerh
ost":"127.0.0.1","payload":"TEST","node":"emqx@REDACTEDHOSTNAME","msg":"TEST","id":"5A42DBE76EE02A1
D6490031280001","headers":{"username":"undefined","protocol":"mqtt","proto_ver":4,"peerhost":"127.0.0.1"},"flags":{"r
etain":false,"dup":false},"event":"message.publish","clientid":"mosq-SplOK4c5Z2Fgr1HWCZ"}

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.

from emqx-web-hook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.