brokeh / pophttp

Add support for HTTP requests to the Logitech pop switches
MIT License
14 stars 1 forks source link

General Q #5

Open funroompc opened 4 years ago

funroompc commented 4 years ago

Hi there,

I installed a docker version and I am trying to get pophttp to send an http request to node red so that I can do some magic with a LIFX bulb (I know, it sounds funny)

However, I noticed that there is a significant time delay in between pressing the button and when node red gets the http request. Sometimes the packet just drops.

I’m wondering if this is normal? Are you still using this and how is your performance?

brokeh commented 4 years ago

I'm using it in Docker and it's fine for me. The latency is a bit under 1 second, which is the same for when I am using commands from the POP bridge directly rather than via pophttp (only some actions use this script).

My setup is Docker version 18.09.7, build 2d0083d running on Ubuntu 18.04 and the default network. All the commands are going to something running direcly on the host system (not in Docker) and are going via it's external IP address (no DNS lookups).

I suspect the latency is either in your docker network or the node red server. This is running a fairly standard Alpine docker image.

To try and narrow down where the latency is, try the below.

  1. Check the latency in pophttp by running it with -vv verbose logging. Make sure you have the latest version of pophttp. I just added timing to the logging, and a previous recent change fixed the console output getting buffered.
    $ docker run --rm -p 56700:56700/udp -v `pwd`/config.ini:/pophttp/config.ini pophttp -vv
    Server started on on 0.0.0.0
    2020-07-12 07:29:13,949 172.17.0.1 resp 200 in 364ms http://example.com/?power=off&hue=24102&saturation=31097&brightness=32768&kelvin=3612
  2. Check the latency from the docker container, outside of python. You can enter the container with a shell and then run wget with the below. Replace example.com with your node red HTTP endpoint.
    $ docker run --rm -it --entrypoint /bin/sh pophttp
    # time wget -q -O /dev/null http://example.com
    real    0m 0.36s
    user    0m 0.00s
    sys     0m 0.00s
  3. Check the latency from the Docker host system. Run this outside of docker. Similarly, replace example.com with your node red endpoint.
    $ time wget -q -O /dev/null http://example.com
    real    0m 0.36s
    user    0m 0.00s
    sys     0m 0.00s

    or if you don't have wget

    $ time curl -s -o /dev/null http://example.com
    real    0m0.398s
    user    0m0.014s
    sys     0m0.000s