MichaIng / DietPi

Lightweight justice for your single-board computer!
https://dietpi.com/
GNU General Public License v2.0
4.79k stars 494 forks source link

gpsd.socket: Failed to receive listening socket ([::1]:2947): Input/output error #5697

Closed keypunch416 closed 1 year ago

keypunch416 commented 2 years ago

Creating a bug report/issue

Required Information

Additional Information (if applicable)

Steps to reproduce

  1. sudo apt update
  2. sudo apt install gpsd gpsd-clients pps-tools
  3. connected USB GPS - u-blox M8030 then lsusb
  4. gpsmon /dev/gps0
  5. configure /etc/default/gpsd via nano
  6. sudo systemctl enable gpsd
  7. sudo systemctl start gpsd
  8. sudo gpsd /dev/gps0 -F /var/run/gpsd.sock
  9. cgps -s /dev/gps0

Expected behaviour

Actual behaviour

Extra details

ls -ls /dev/gps*
0 lrwxrwxrwx 1 root root 7 Aug 22 15:23 /dev/gps0 -> ttyACM0
MichaIng commented 2 years ago

Many thanks for your report.

Job gpsdctl@ttyACM0.service/start failed with result 'dependency'

Can you show the output of:

systemctl cat gpsdctl@ttyACM0
keypunch416 commented 2 years ago

I was out much of day and in course of the day more odd nonsense occurred. I need to see if what I have done addresses one of the odd behaviours. I also do not understand why all of sudden Linux changed /dev/GPSx. i have seen this sudden with no reason USB port assignment change for no reason with Raspberry Pi OS on system that uses number of USB devices to feed weather data. This means yet another Linux or udev related issue that I would suggest is due to Linux Kernel and/or udev. That said this GPS via USB is real mess and I had stability I thought until something happened while I was out for about 8 hours today. So I had added even more to the complex changes I have made to see if I at least solved one of the issues, new one related to IPV6 that occurred while I was out and was not presenting in last few days with the many changes I have effected based on my initial findings and work of number of days of testing.

keypunch416 commented 2 years ago

For reasons unknown secondary issues have arisen so I reset the gpsd systemd files back to original installed by gpsd package. This was the state of the gpsd systemd files when reported this issue and the related findings.

The output you requested is:

systemctl cat gpsdctl@ttyACM0
# /lib/systemd/system/gpsdctl@.service
[Unit]
Description=Manage %I for GPS daemon
Requires=gpsd.socket
BindsTo=dev-%i.device
After=dev-%i.device

[Service]
Type=oneshot
Environment="GPSD_SOCKET=/run/gpsd.sock"
EnvironmentFile=-/etc/default/gpsd
RemainAfterExit=yes
ExecStart=/bin/sh -c "[ \"$USBAUTO\" = true ] && /usr/sbin/gpsdctl add /dev/%I || :"
ExecStop=/bin/sh -c "[ \"$USBAUTO\" = true ] && /usr/sbin/gpsdctl remove /dev/%I || :"
MichaIng commented 2 years ago

So it seems gpsd.socket failed. Can you check:

systemctl status gpsd.socket
systemctl cat gpsd.socket
ls -l /run/gpsd.sock
keypunch416 commented 2 years ago

Bear in mind there may be delays for some of the requested information at times as I am working through a number of issues, including issues I have yet to report, clusters of medical issues, and coding issues. The coding issues that are just me issues in porting and/or improving seismic application related code I have written. The N2P was intended to be used for recording earthquakes around the world and I have missed a number of, including the significant events in the Indonesia area in last 36 hours due to 'Unable to enable SPI /dev/spidev0.0' #5645.

As gpsd.socket failed to run there was no /run/gpsd.sock.

/usr/lib/systemd/system/gpsd.socket:

[Unit]
Description=GPS (Global Positioning System) Daemon Sockets

[Socket]
ListenStream=/run/gpsd.sock
ListenStream=[::1]:2947
ListenStream=127.0.0.1:2947
# To allow gpsd remote access, start gpsd with the -G option and
# uncomment the next two lines:
# ListenStream=[::]:2947
# ListenStream=0.0.0.0:2947
SocketMode=0600
BindIPv6Only=yes

[Install]
WantedBy=sockets.target

/usr/lib/systemd/system/gpsd.service

[Unit]
Description=GPS (Global Positioning System) Daemon
Requires=gpsd.socket
# Needed with chrony SOCK refclock
After=chronyd.service

[Service]
Type=forking
EnvironmentFile=-/etc/default/gpsd
ExecStart=/usr/sbin/gpsd $GPSD_OPTIONS $OPTIONS $DEVICES

[Install]
WantedBy=multi-user.target
Also=gpsd.socket
2022-08-22 18:27:51 +0000 UTC : 1661192871  n2p@dietpi tty0 /etc/default $ sudo systemctl start gpsd.socket
Job failed. See "journalctl -xe" for details.
2022-08-22 18:28:48 +0000 UTC : 1661192928  n2p@dietpi 62FE9A82 tty0 /etc/default $ sudo systemctl status gpsd.socket
● gpsd.socket - GPS (Global Positioning System) Daemon Sockets
     Loaded: loaded (/lib/systemd/system/gpsd.socket; enabled; vendor preset: enabled)
     Active: failed (Result: resources)
   Triggers: ● gpsd.service
     Listen: /run/gpsd.sock (Stream)
             [::1]:2947 (Stream)
             127.0.0.1:2947 (Stream)
        CPU: 1ms

Aug 22 18:08:35 dietpi systemd[1]: Failed to listen on GPS (Global Positioning System) Daemon Sockets.
Aug 22 18:27:51 dietpi systemd[1]: gpsd.socket: Failed to receive listening socket ([::1]:2947): Input/output error
Aug 22 18:27:51 dietpi systemd[1]: gpsd.socket: Failed to listen on sockets: Input/output error
Aug 22 18:27:51 dietpi systemd[1]: gpsd.socket: Failed with result 'resources'.
Aug 22 18:27:51 dietpi systemd[1]: Failed to listen on GPS (Global Positioning System) Daemon Sockets.
Aug 22 18:28:48 dietpi systemd[35008]: gpsd.socket: Failed to create listening socket ([::1]:2947): Cannot assign requested address
Aug 22 18:28:48 dietpi systemd[1]: gpsd.socket: Failed to receive listening socket ([::1]:2947): Input/output error
Aug 22 18:28:48 dietpi systemd[1]: gpsd.socket: Failed to listen on sockets: Input/output error
Aug 22 18:28:48 dietpi systemd[1]: gpsd.socket: Failed with result 'resources'.
Aug 22 18:28:48 dietpi systemd[1]: Failed to listen on GPS (Global Positioning System) Daemon Sockets.
2022-08-22 18:29:03 +0000 UTC : 1661192943  n2p@dietpi tty0 /etc/default $
2022-08-22 18:08:35 +0000 UTC : 1661191715  n2p@dietpi tty0 ~ $ journalctl -xe
[snip]
Aug 22 15:23:27 dietpi systemd[33851]: gpsd.socket: Failed to create listening socket ([::1]:2947): Cannot assign requested address
Aug 22 15:23:27 dietpi systemd[1]: gpsd.socket: Failed to receive listening socket ([::1]:2947): Input/output error
Aug 22 15:23:27 dietpi systemd[1]: gpsd.socket: Failed to listen on sockets: Input/output error
Aug 22 15:23:27 dietpi systemd[1]: gpsd.socket: Failed with result 'resources'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ The unit gpsd.socket has entered the 'failed' state with result 'resources'.
Aug 22 15:23:27 dietpi systemd[1]: Failed to listen on GPS (Global Positioning System) Daemon Sockets.
░░ Subject: A start job for unit gpsd.socket has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ A start job for unit gpsd.socket has finished with a failure.
░░ 
░░ The job identifier is 2674 and the job result is failed.
Aug 22 15:23:27 dietpi systemd[1]: Dependency failed for Manage ttyACM0 for GPS daemon.
░░ Subject: A start job for unit gpsdctl@ttyACM0.service has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ A start job for unit gpsdctl@ttyACM0.service has finished with a failure.
░░ 
░░ The job identifier is 2605 and the job result is dependency.
Aug 22 15:23:27 dietpi systemd[1]: gpsdctl@ttyACM0.service: Job gpsdctl@ttyACM0.service/start failed with result 'dependency'.
[snip]
Aug 22 16:20:09 dietpi systemd[34733]: gpsd.socket: Failed to create listening socket ([::1]:2947): Cannot assign requested address
Aug 22 16:20:09 dietpi systemd[1]: gpsd.socket: Failed to receive listening socket ([::1]:2947): Input/output error
Aug 22 16:20:09 dietpi systemd[1]: gpsd.socket: Failed to listen on sockets: Input/output error
Aug 22 16:20:09 dietpi systemd[1]: gpsd.socket: Failed with result 'resources'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ The unit gpsd.socket has entered the 'failed' state with result 'resources'.
Aug 22 16:20:09 dietpi systemd[1]: Failed to listen on GPS (Global Positioning System) Daemon Sockets.
░░ Subject: A start job for unit gpsd.socket has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ A start job for unit gpsd.socket has finished with a failure.
░░ 
░░ The job identifier is 2751 and the job result is failed.
[snip]
Aug 22 18:08:35 dietpi systemd[34939]: gpsd.socket: Failed to create listening socket ([::1]:2947): Cannot assign requested address
Aug 22 18:08:35 dietpi systemd[1]: gpsd.socket: Failed to receive listening socket ([::1]:2947): Input/output error
Aug 22 18:08:35 dietpi systemd[1]: gpsd.socket: Failed to listen on sockets: Input/output error
Aug 22 18:08:35 dietpi systemd[1]: gpsd.socket: Failed with result 'resources'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ The unit gpsd.socket has entered the 'failed' state with result 'resources'.
Aug 22 18:08:35 dietpi systemd[1]: Failed to listen on GPS (Global Positioning System) Daemon Sockets.
░░ Subject: A start job for unit gpsd.socket has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ A start job for unit gpsd.socket has finished with a failure.
░░ 
░░ The job identifier is 2895 and the job result is failed.
Aug 22 18:08:35 dietpi systemd[1]: Dependency failed for GPS (Global Positioning System) Daemon.
░░ Subject: A start job for unit gpsd.service has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ A start job for unit gpsd.service has finished with a failure.
░░ 
░░ The job identifier is 2826 and the job result is dependency.
Aug 22 18:08:35 dietpi systemd[1]: gpsd.service: Job gpsd.service/start failed with result 'dependency'.
MichaIng commented 1 year ago

Do you have IPv6 enabled?

ip -6 a

Or is something else listening on this port?

ss -tulpn | grep ':2947'
MichaIng commented 1 year ago

@keypunch416 Does your issue persist?

mclendon99 commented 1 year ago

I had the same issue with the same exact symptoms. The clue is that "ip -6 a" has no output, i.e. IPv6 is not enabled. So, do a clean override of the systemd stuff

sudo cp /lib/systemd/system/gpsd* /etc/systemd/system

and edit /etc/systemd/system/gpsd.socket to comment out the ipv6 config. Here's mine:

Description=GPS (Global Positioning System) Daemon Sockets

[Socket]
ListenStream=/var/run/gpsd.sock
#ListenStream=[::1]:2947
ListenStream=127.0.0.1:2947
# To allow gpsd remote access, start gpsd with the -G option and
# uncomment the next two lines:
# ListenStream=[::]:2947
# ListenStream=0.0.0.0:2947
SocketMode=0600
#BindIPv6Only=ipv6-only

[Install]
WantedBy=sockets.target

The system MUST be rebooted. Restarting the service won't do it, obviously.

MichaIng commented 1 year ago

Many thanks for reporting. Makes much sense that the socket fails if IPv6 is disabled, as it is explicitly configured to listen on both, IPv4 and IPv6.

A reboot shouldn't be required, but instead:

systemctl daemon-reload
systemctl restart gpsd.socket
systemctl restart gpsd
MichaIng commented 1 year ago

Marking as closed due to outstanding reply of OP. Feel free to reopen if either enabling IPv6 or disabling it in the socket does not help in your case.