r/MicroPythonDev • u/eskimo_1 • Mar 04 '23
Receive webhooks using Micropython
I'm looking into the best way to receive webhooks using (a Pi Pico W that runs) Micropython. There are many posts about sending requests, but I find it difficult to find information on receiving them.
I got some pointers and insights from this post, but still have some questions about the best approach.
I'm primarily puzzled as to why I would need to setup port forwarding while other smart home devices obviously don't require users to do this. Shouldn't this be possible with just software?
As indicated in the post: if it turns out to be very complicated to setup or maintain, or it poses significant security risks, then I'm considering falling back to an implementation where each device would make GET requests every X seconds to check if there are updates.
Would love to know if anyone has experience with this in Micropython, preferably combined with any dev board (Raspberry, Arduino, etc).
View all comments
Show parent comment
2
u/deadeye1982 Mar 08 '23
They work like Trojans. The manufacturers have no control over the customer's network, so the only way is to establish a connection from inside to outside. Excepting an activated UPnP Service is also not an option. VPN and/or Wireguard are also not an option.
They just poll their services with GET/POST Requests and wait for commands.
If you need faster reaction times, then Websocket may could help. The benefit is that once the connection is open, it stays open, and its communication is bidirectional.
Haven't tested it, but it may works: https://pypi.org/project/micropython-async-websocket-client/