upsd write() failed for 127.0.0.1: Broken pipe

Bug #753661 reported by Virus
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nut (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: nut

I have Powercom UPS and trying configure it with NUT.

lsusb:
Bus 006 Device 002: ID 0d9f:0004 Powercom Co., Ltd

ups.conf:
[powercom]
        driver = usbhid-ups
        port = /dev/usb/hiddev0
        productid = 0004
        desc = "My UPS"

but when i trying run `upsc powercom` got this output:
--------------
battery.charge: 99
battery.charge.low: 10
battery.charge.warning: 30
battery.date: 2009/12/23
battery.runtime: 24576
battery.type: PbAc
--------------

and `upsd[24062]: write() failed for 127.0.0.1: Broken pipe` in /var/log/daemon.log

how i can fix this?

ubuntu:
Description: Ubuntu 10.10
Release: 10.10

I got this error with 2.4.3-1ubuntu5 packages, then download nut_2.6.0-1ubuntu2_amd64.deb and libupsclient1_2.6.0-1ubuntu2_amd64.deb, but new version did not fix problem.

Related branches

Revision history for this message
Arnaud Quette (aquette) wrote : Re: [Bug 753661] [NEW] upsd write() failed for 127.0.0.1: Broken pipe

2011/4/7 Virus <email address hidden>

> Public bug reported:
>
> Binary package hint: nut
>
> I have Powercom UPS and trying configure it with NUT.
>
> lsusb:
> Bus 006 Device 002: ID 0d9f:0004 Powercom Co., Ltd
>
> ups.conf:
> [powercom]
> driver = usbhid-ups
> port = /dev/usb/hiddev0
>

putting "auto" is sufficient here

       productid = 0004
>

this productid should be added to the driver.
before that, I need the output f an lsusb -v -d 0x0d9f:0004

       desc = "My UPS"
>
but when i trying run `upsc powercom` got this output:
> --------------
> battery.charge: 99
> battery.charge.low: 10
> battery.charge.warning: 30
> battery.date: 2009/12/23
> battery.runtime: 24576
> battery.type: PbAc
> --------------
>
> and `upsd[24062]: write() failed for 127.0.0.1: Broken pipe` in
> /var/log/daemon.log
>
> how i can fix this?
>

good question!

is the driver still running?
what is your start method (ie using invoke-rc.d or alike, or directly
starting components manually)?
what is the content of your upsd.conf?
after having stopped previous instance (invoke-rc.d nut stop), what is the
output of:
$ sudo upsd -v

then, stop upsd (sudo upsd -c stop)
and start in 3 separate consoles:
$ sudo upsd -DDD
$ sudo /lib/nut/usbhid-ups -DDDDD -a powercom
$ upsc powercom

and send back the various output.

cheers,
Arnaud
--
Linux / Unix Expert R&D - Eaton - http://powerquality.eaton.com
Network UPS Tools (NUT) Project Leader - http://www.networkupstools.org/
Debian Developer - http://www.debian.org
Free Software Developer - http://arnaud.quette.free.fr/

Revision history for this message
Virus (lanchpad) wrote :

Files

Revision history for this message
Virus (lanchpad) wrote :

Files #2

Revision history for this message
Virus (lanchpad) wrote :

Files #3

Revision history for this message
Virus (lanchpad) wrote :

lsusb

Revision history for this message
Virus (lanchpad) wrote :

Attachments not working correctly.

Revision history for this message
Virus (lanchpad) wrote :

Seems driver respond correctly, but upsd return "Broken pipe" after:
  25.768861 write: [destfd=6] [len=35] [VAR powercom battery.type "PbAc
"]

Two lines?

Revision history for this message
Arnaud Quette (aquette) wrote : Re: [Bug 753661] Re: upsd write() failed for 127.0.0.1: Broken pipe

2011/4/16 Virus <email address hidden>

> Seems driver respond correctly, but upsd return "Broken pipe" after:
> 25.768861 write: [destfd=6] [len=35] [VAR powercom battery.type "PbAc
> "]
>
> Two lines?
>
>
yup, but upsd sends everything. and upsc brokes the pipe.
the driver is still there, so the issue is really between upsc and upsd.

2 more tests, still with upsd running in debug mode:
$ upsc battery.type
$ upsc ups.status

cheers,
Arno

Revision history for this message
Virus (lanchpad) wrote :

$ upsc battery.type
Error: Unknown UPS
$ upsc ups.status
Error: Unknown UPS

Revision history for this message
Arnaud Quette (aquette) wrote :

2011/4/16 Virus <email address hidden>

> $ upsc battery.type
> Error: Unknown UPS
> $ upsc ups.status
> Error: Unknown UPS
>

damn, I missed a bit (ie the "device name"):
$ upsc powercom battery.type
Error: Unknown UPS
$ upsc powercom ups.status
Error: Unknown UPS

don't forget to run upsd in debug mode, as in the previous test.
I need to see how it react.

cheers
Arno

Revision history for this message
Virus (lanchpad) wrote :

I was done:
$ for command in battery.charge battery.charge.low battery.charge.warning battery
.date battery.runtime battery.type device.mfr device.model device.serial device.type driver.name dr
iver.parameter.pollfreq driver.parameter.pollinterval driver.parameter.port driver.parameter.produc
tid driver.version driver.version.data driver.version.internal input.frequency input.voltage input.
voltage.nominal output.frequency output.voltage output.voltage.nominal ups.beeper.status ups.date u
ps.delay.shutdown ups.delay.start ups.load ups.mfr ups.model ups.productid ups.serial ups.status up
s.test.result ups.timer.shutdown; do echo -n "$command "; upsc powercom $command; done

battery.charge 100
battery.charge.low 10
battery.charge.warning 30
battery.date 2009/12/23
battery.runtime 25600
battery.type PbAc
device.mfr POWERCOM Co.,LTD
device.model HID UPS Battery
device.serial 004-0D9F-000
device.type ups
driver.name usbhid-ups
driver.parameter.pollfreq 30
driver.parameter.pollinterval 2
driver.parameter.port /dev/usb/hiddev0
driver.parameter.productid 0004
driver.version 2.6.0
driver.version.data PowerCOM HID 0.2
driver.version.internal 0.35
input.frequency 50.0
input.voltage 210.0
input.voltage.nominal 220
output.frequency 50.0
input.voltage 210.0
input.voltage.nominal 220
output.frequency 50.0
output.voltage 210.0
output.voltage.nominal 220
ups.beeper.status enabled
ups.date 2009/12/23
ups.delay.shutdown 20
ups.delay.start 60
ups.load 7
ups.mfr POWERCOM Co.,LTD
ups.model HID UPS Battery
ups.productid 0004
ups.serial 004-0D9F-000
ups.status OL
ups.test.result Done and passed
ups.timer.shutdown 0

without any 'Broken pipe'.

Revision history for this message
Arnaud Quette (aquette) wrote :

so what if you issue again an "upsc powercom"?
does it still broke the pipe?
is your issue 100 % reproducible?

my guess, is ATM, that the faulty end-of-line marker in battery.type is
causing parseconf to close prematurely the connexion, while upsd is still
sending data.
which explains why unit requests works, while getting the whole tree
fails...
the only way to ensure this is the root cause is to fix the function that
retrieve strings from the device's indexed table, to trim EOL, and check if
it solves your issue.

would you be ready to test a fix using subversion?

cheers,
Arno

Revision history for this message
Virus (lanchpad) wrote :

yes, it 100 % reproducible.

i am ready to test svn version.

Revision history for this message
Arnaud Quette (aquette) wrote :

2011/4/18 Virus <email address hidden>

> yes, it 100 % reproducible.
>

I also managed to reproduce it using dummy-ups (the simulation driver) and
injecting the error on the same variable:
adding a newline (ie "\n") results in a broken pipe on upsc side.

> i am ready to test svn version.
>

ok, here we go:
1) checkout an svn copy using:
$ svn co svn://svn.debian.org/nut/trunk

2) configure it using (Debian arguments, limited for the current test scope
; should be sufficient):
--prefix=/usr \
            --exec-prefix=/ \
            --sysconfdir=/etc/nut \
            --mandir=/usr/share/man \
            --libdir=/lib \
            --includedir=/usr/include \
            --without-all \
            --with-usb \
            --enable-static \
            --with-statepath=/var/run/nut \
            --with-altpidpath=/var/run/nut \
            --with-drvpath=/lib/nut \
            --with-pidpath=/var/run/nut \
            --datadir=/usr/share/nut \
            --with-pkgconfig-dir=/usr/lib/pkgconfig \
            --with-user=nut --with-group=nut

3) apply the attached patch
$ patch -p0 < /path/to/virus.patch

4) make as usual, ie
$ make

5) stop all previous NUT instances, then launch the new driver and upsd
$ sudo drivers/usbhid-ups -a powercom
$ sudo server/upsd -DDD

6) now issue your "upsc of death"
$ upsc powercom

everything should behave fine.
Remember that it's a "blind patch": I've not validated the above configure
line, nor the patch itself!

cheers,
Arnaud
--
Linux / Unix Expert R&D - Eaton - http://powerquality.eaton.com
Network UPS Tools (NUT) Project Leader - http://www.networkupstools.org/
Debian Developer - http://www.debian.org
Free Software Developer - http://arnaud.quette.free.fr/

Revision history for this message
Virus (lanchpad) wrote :

It`s working great! Many thanks!

Revision history for this message
Arnaud Quette (aquette) wrote :

2011/4/18 Virus <email address hidden>

> It`s working great! Many thanks!
>

excellent, thanks for the feedback.
I've just committed it upstream (r2972)

the changeset will be available on the NUT Trac mirror (just give it some
minutes to sync):
http://trac.networkupstools.org/projects/nut/changeset/2972

I'll leave up to our Ubuntu friends to generate an updated package.
I have to note that importance is low since this should not affect the
protection (ie upsmon is still working fine).
@Virus: can you please confirm this point?

cheers,
Arnaud
--
Linux / Unix Expert R&D - Eaton - http://powerquality.eaton.com
Network UPS Tools (NUT) Project Leader - http://www.networkupstools.org/
Debian Developer - http://www.debian.org
Free Software Developer - http://arnaud.quette.free.fr/

Revision history for this message
Virus (lanchpad) wrote :

Yeah, upsmon working fine. I was checked it now by unplug power cable. upsmon was generate alerts "UPS powercom@localhost on battery" and "UPS powercom@localhost on line power" after plug cable back.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package nut - 2.6.0-1ubuntu3

---------------
nut (2.6.0-1ubuntu3) natty; urgency=low

  * debian/patches/backport-fix-lp753661.patch: Backport fix
    to trim extraneous end-of-line, in buggy HID string tables,
    which results in upsc breaking the communication pipe.
    (LP: #753661)
 -- Chuck Short <email address hidden> Wed, 20 Apr 2011 10:47:05 -0400

Changed in nut (Ubuntu):
status: New → Fix Released
Revision history for this message
Arnaud Quette (aquette) wrote : Re: [Nut-upsuser] PowerCOM BNT-800AP (0d9f:0004)

Hi Pavel,

2011/10/4 Павел Гуменюк <email address hidden>:
> Hello.
> I've been trying to got it work but haven't luck.
> I'm using NUT 2.6.0-1 under Windows XP with libusb driver installed
> (USB\VID_0D9F&PID_0004&REV_0001).
> I had tryed all options with  such config:
>
> PWCOM]
>         driver = usbhid-ups
>         port = auto
>         vendorid = 0d9f
>         desc = "Powercom BNT-800AP"
>       type=BNT

as per a previous report on Ubuntu, we know that this UPS is supported:
https://bugs.launchpad.net/ubuntu/+source/nut/+bug/753661

that being said, it seems I've not completed my actions and committed
a patch for this new device ID.
Fixed in the development version (trunk), r3265.

Also note that the "type" option is supported by the "powercom"
driver, not the "usbhid-ups" one.

cheers,
Arnaud
--
Linux / Unix Expert R&D - Eaton - http://powerquality.eaton.com
Network UPS Tools (NUT) Project Leader - http://www.networkupstools.org/
Debian Developer - http://www.debian.org
Free Software Developer - http://arnaud.quette.free.fr/

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.