adsbexchange-netcat ... SOCAT goes to 100% CPU if target host is not resolved.

Discussion in 'Feeding' started by john, Jul 29, 2018.

  1. john

    john Member

    There is a reported bug in SOCAT that causes it to go to 100% CPU if the target host is unknown. It isn't for the version I'm running however. But I hit this issue after a power failure at our house.

    SOCAT is running, and showing 100% CPU in the TOP command. It is not feeding anything to my custom feed at adsbexchange though. You have to use a KILL -9 processsID to get rid of it.

    Presumably my internet connection didn't get up and running before the SOCAT ran, so there was no DNS available when SOCAT tried to resolve feed.adsbexchange.com. I'm guessing the solution is to build in a delay prior to running SOCAT. Any other bright ideas?
     
  2. James

    James Guest

  3. john

    john Member

    yes, that's the one. Supposedly fixed on SOCAT 1.7.3, but my system, created from the FA image, has SOCAT at 1.7.2, which is not suppose to have this bug. But it is easy to replicate. Simply enter something like: socat -u TCP:localhost:30005 TCP:feed.some.nonexistant.server:30005
    Then check TOP.

    I increased the delay at the beginning of adsbexchange-netcat_maint.sh to hopefully be able to connect to a DNS after a power failure.
     
  4. James

    James Guest

    you could just upgrade socat to latest .. or update to the new FA image that is a mess apparently

    sudo apt update
    sudo apt upgrade

    sudo apt remove socat
    sudo apt install socat

    I've been reluctant to make a FA image and support it due to the amount of shenanigans that goes on.

    from source

    http://www.dest-unreach.org/socat/

    2017-01-25: Socat version 1.7.3.2 fixes uninterruptable hang / CPU loop on host resolution problems, some compile problems, and lots of other bugs and porting issues (socat-1.7.3.2.tar.gz, socat-1.7.3.2.tar.bz2, socat-1.7.3.2.patch.gz).


    I'll get this updated in our next release for ADSBx custom.
     
    Last edited by a moderator: Jul 29, 2018
    MDA likes this.
  5. john

    john Member

    thanks. I may give that a try. cheers.

    Update: no luck. It came back at exactly the same level: 1.7.2.4-2 which is the one that's in Jessie. ...Makes sense I guess since I'm running Jessie. Oh well, not to worry. I think lengthening the delay at startup until the network and ISP connection is running should solve the problem. Thanks for your suggestion though.
     
    Last edited: Jul 29, 2018
  6. Jhonny Monclair

    Jhonny Monclair Active Member

    You could roll back to the old netcat...actually the old image, before socat, was using netcat.
    It lacks some evolute features of socat but at least it doesnt crash in a 100% cpu loop
     
  7. john

    john Member

    True, but I went to socat because nc wasn’t that reliable for me. I lengthened the startup delay so hopefully we should be ok. I’ll find out the next time we have a power failure!
     
    Jhonny Monclair likes this.
  8. James

    James Guest

    I wait 30 seconds on the custom image. You can wait for network to be up before starting things using systemd. I might do this in the future for images.


    #!/bin/bash
    ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || echo error

    Something like that in your launch scripts

    OR use services.

    https://raspberrypi.stackexchange.c...t-after-an-internet-connection-is-established

    ADSBx custom will likely move to something that uses .service files and maybe even monit to keep things running. I will admit the bash scripts are simple and this would over complicate troubleshooting.
     
  9. john

    john Member

    Yes, I use services for some other stuff, but I couldn’t see how to wait until the external internet connection is up. I’d appreciate any ideas anyone might have in that regard. I could see how to wait for the network to come up, but that is only the LAN in the house I think. While I run my own DNS server it really just caches things, and in the event of a power failure the cache is lost so the query would have to be forwarded to an external DNS. TIA
     
  10. James

    James Guest

    Just try to ping something out there in the Internet. Like .. google.com
     
  11. James

    James Guest

  12. john

    john Member

    I finally settled on this. Decided to ping feed.adsbexchange.com since that's the site I actually what to connect to. For some reason the indention doesn't show up properly. sorry.

    #!/bin/sh
    # test for connection to feed.adsbexchange.com for internet connection to come up after power failure, othewise socat goes to 100% CPU

    while true
    do
    if ping -q -c 1 -W 1 feed.adsbexchange.com >/dev/null 2>&1
    then
    # echo "connected"
    /usr/bin/socat -u TCP:localhost:30005 TCP:feed.adsbexchange.com:51023
    fi
    # not connected to wait a bit and try again
    # echo "not connected"
    sleep 5
    done
     
    Last edited: Jul 31, 2018
    James likes this.
  13. James

    James Guest

    I'll adapt this for the base images.