Page 1 of 2

ListenProcess error[Errno 22] Invalid argument

PostPosted: Fri Mar 29, 2019 10:24 am
by dkillmer
Hi, there.

The UniFiAP plugin has worked flawlessly for months and this week it stopped receiving the status of unifi created devices. If I restart the plugin or restart the UniFi AP it will work again for a short time. I have tried restarting everything but the problem persists. From everything we can tell, all our network devices are online and working properly.

I am receiving the following messages in the Indigo event log when it stops receiving the status:
ListenProcess error[Errno 22] Invalid argument
APdict stop in getMessage stop=True for ip#xxx.xxx.xxx.xxx.

I had two updates this week, so it is likely one of these that caused the problem: the latest MacOS update and the latest UniFi controller/Cloud Key firmware update.

Is anyone else having this problem?

Thank you!

Dennis

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Fri Mar 29, 2019 10:28 am
by kw123
I am out of town. Will check after april10.


Sent from my iPhone using Tapatalk

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Fri Apr 05, 2019 10:29 am
by dkillmer
Hi, Karl.

The error went away after I set "use controller info" to off and reloaded the plugin.

Thank you for all your work on this plugin and it is the best I have found for determining if we are home or away.

Dennis

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Mon Apr 15, 2019 10:59 am
by dkillmer
Update - these errors eventually started showing up on my APs and device status for online devices says expired. Restarting the plugin works for a short time.

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Mon Apr 15, 2019 12:00 pm
by kw123
Today I got my second eye fixed.
Can do some programming again starting tomorrow.

give me a day. will be checking


Karl

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Sun Apr 21, 2019 5:42 pm
by kw123
thank to Wouter to point out: there are option for the "tail" commands (the plugin listens to log files on the unify devices with tail-f or tail -F)

Newer versions of switches .. AP software can do "tail -F" older need to use "tail -f"

You need to set those options in config for
-USG
-switches
-AP
-video (if you use that)
-no option for the controller software. tail -F should always work (well not on windows)

tail-F has the benefit that it will "tail" rotating log files while "tail -f" will stop working when a logfile gets recycled on the switches ...

the plugin will cover that, but it will need several minutes to detect that there is no response from tail-f and the will relaunch the tail-f command to the sw/ap.. that has a new logfile.


That option was introduced some time ago, just forgot that it has this side effect.

Karl

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Sun Apr 21, 2019 6:33 pm
by dkillmer
Thank you, Karl and Wouter! I will give this a try.

Dennis

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Tue Apr 23, 2019 10:50 am
by kw123
Dennis

it seems this a deeper problem.

I can not recreate the problem no matter what, Wouter can

it must be either OSX, python,plugin

I have added an error recovery for this special issue.
it will kill the listener and restart it. Not a fix but a work around

could you try this one:
https://www.dropbox.com/s/ffijjgzds5aougs/uniFiAP.indigoPlugin.zip?dl=1

Karl

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Tue Apr 23, 2019 11:35 am
by howartp
Not related to case-sensitive installs of OSX?


Sent from my iPhone using Tapatalk Pro

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Tue Apr 23, 2019 11:37 am
by kw123
Have not check that one. But the paths should be ok

Good suggestion will check.

Karl.


Sent from my iPhone using Tapatalk

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Tue Apr 23, 2019 11:45 am
by kw123
the paths and files names are correct w upper / lower case.
And the read is listening to a pipe not reading a file (name)

this has worked for years, and for some it just stopped now. Also older plugin versions have the same issue.


this is a simplified version
Code: Select all
#! /usr/bin/env python
# -*- coding: utf-8 -*-
####################

import subprocess
import fcntl
import os
import sys
import time

uid = "xx"
passwd = "xx"
ip =  "192.168.1.xx"

#cmd= "/usr/bin/expect   execLog.exp '"+uid+"' '"+passwd+"' "+ip+" BZ.v '/usr/bin/tail -F /var/log/messages'"

cmd = "/usr/bin/expect   dictLoop.exp  '"+uid+"' '"+passwd+"' "+ip+" BZ.v xxxThisIsTheEndTokenxxx 60 40 \"mca-dump | sed -e 's/^ *//'\"   /var/log/messages"

print cmd
ListenProcess = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)

# set the O_NONBLOCK flag of ListenProcess.stdout file descriptor:
flags = fcntl.fcntl(ListenProcess.stdout, fcntl.F_GETFL)  # get current p.stdout flags
fcntl.fcntl(ListenProcess.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)


while True:
   try:
      linesFromServer = os.read(ListenProcess.stdout.fileno(),32767) ## = 32k
      print unicode(linesFromServer)
   except   Exception, e:
      if unicode(e).find("[Errno 35]") == -1:    # "Errno 35" is the normal response if no data, if other error: exit
         if len(unicode(e)) > 5:
            print "os.read(ListenProcess.stdout.fileno(),32767) has error in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e)
            print "... ListenProcess for ip: "+ip+"    ListenProcessObject: "+ unicode(ListenProcess)
            try:     print "..."+ unicode(ListenProcess.stdout)
            except: print "...  ListenProcess.stdout  not printable"
            try:     print "..."+ unicode(ListenProcess.stdout.fileno())
            except: print "...  ListenProcess.stdout.fileno()  not printable"
   time.sleep(1)

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Tue Apr 23, 2019 7:12 pm
by dkillmer
Karl,

This started happening right after the latest MacOS update.

I tried the dropbox link and I get "Error (404) We can't find the page you're looking for".

Sure appreciate all your efforts,

Dennis

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Tue Apr 23, 2019 7:14 pm
by kw123
https://www.dropbox.com/s/lrbkt6hvh3qbo ... n.zip?dl=1

Try this one.


Sent from my iPhone using Tapatalk

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Tue Apr 23, 2019 7:22 pm
by dkillmer
That worked, thanks!

I purchased my devices in December, 2017 and wondered if I should use new version or old version of the the tail command configuration.

Thanks again,
Dennis

Re: ListenProcess error[Errno 22] Invalid argument

PostPosted: Tue Apr 23, 2019 7:23 pm
by kw123
The new one with the -F


and could you open terminal and type:
python --version

mine shows:
Python 2.7.10
in high sierra and mojave

Sent from my iPhone using Tapatalk