-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"socket connect failed" but only if starting pigpiod via systemctl #203
Comments
I'm afraid systemctl is a black art as far as I am concerned. I use the raspberrypi.org supplied service file (as installed with Raspbian full). I have no real understanding of how it works. Perhaps someone else can help. |
The contents of the service file for reference:
So systemctl is running it slightly differently, passing the -l flag. But I'm trying to access it from localhost anyway so it should make no difference? In pigs.c the default is to open a connection to In pigpio.h these defaults are set to 127.0.0.1 and 8888. Suspect this is caused by the latest version of Raspbian having ipv6 taking precedence over ipv4. Test on older version of Raspbian (Raspbian Lite 8 Jessie)
So weirdly even though I've started this via systemd, it seems to have bound to all ipv4 addresses? That explains why it works anyway. So in summary: In Raspbian 8, by default pigpiod binds to the ipv4 address for localhost on port 8888 and pigs by default tries to connect to it on the ipv4 address for localhost on port 8888 so it works fine. In Raspbian 9, by default pigpiod binds to the ipv6 address for localhost on 8888, pigs still tries to connect to the ipv4 address by default and fails since Suspect that setting the address in the environment will fix this but I've run out of lunch break so I'll try it tomorrow. |
Thanks for discovering the issue, debugging it and hopefully resolving it! I do not plan to move my hosts running |
@ralphhughes is perfectly right! As a quick fix, I suggest to change the
This makes the daemon bind to IPv4. The longterm solution should be to make the daemon listen to both IPv4 and IPv6, I guess. |
Tagging this with W/A and Retest since later versions of pigpio have altered the handling of localhost IP. |
@maxnet , |
Ah, yeah.
Actually, "localhost" do should resolve to both ::1 and 127.0.0.1
If a hostname resolves to multiple addresses, the client really should try connecting to all of them before giving up. |
My host resolves localhost to both 127.0.0.1 and ::1. Yet when I request to connect to 'localhost' it chooses (I suppose) to use the IPv4. I don't think the burden should be placed on the clients. You would be asking a lot of apps to change their code. |
*clients == apps in this case. |
The client actually has a for() loop that do is supposed to try all addresses: https://github.com/joan2937/pigpio/blob/master/pigs.c#L134 Will take a look why it is not working, when I have time. |
@maxnet, I appreciate your willingness to look into this. However, my guidance is to try to solve this in |
Sorry, don't have time to rewrite the server code to support multiple listen sockets.
Doubt those have same bug. |
Then seems like a possible solution is to leave the socket bound to IPv6 "any" and in the I'd attempt this myself but I'm not experienced in the network stack enough to know how to map IPv4 to IPv6 and do the address comparison. |
The connect code in client is fine. That said. |
For those following this thread, a work-around for this issue is posted on the wiki here. |
Confirmed this issue is resolved after upgrade to pigpio V73. |
Note that on a fresh install of v79 (rpi3b, bullseye), using
The workaround of changing
changes it to plain tcp (v4), but only listening on localhost. Q: -n 0.0.0.0 causes it to error. Is there some way to make it listen on all IPv4 addresses? - i.e. to specify ipv4, but enable remote, without explicitly specifying the local IP address? |
From the doc:
What are the options on |
ahh... When you 'Confirmed this issue is resolved after upgrade to pigpio V73' in 2020, what was/is your startup line, and what was it listening on? (p.s. I'm using your pigpio-client - nice and simple. Will fork and propose some extra examples soon, plus maybe a node-red node). |
with just -n 0.0.0.0: :(
line 148 in pigpiod: if I specify
but pigpio-client does not see it. If I use just
and a local pigpio-client works. I have not tested a remote client. Note that as originally installed with the -l option:
pigpio-client cannot connect:
So, it seems that the -l option makes it only bind to ipv6 on the local address. Conclusions: 1/ the default apt-get install 2/ the -n option cannot be used to cause it to bind to both ipv4 and ipv6. 3/ the default apt-get install should probably be 4/ Whooo... and |
No, it has been too long ago.
I generally agree with that statement. |
The problem is that the service has to be started by root. Adding:
before the |
Not sure if I'm using it wrong but I can't seem to get pigpiod working if I start it as a service via systemd. Log of my actions as follows:
Made sure pigpiod was not running and then started it via systemctl:
Noticed that it seemed to have only bound to the ipv6 address ::1?
Killed that version and started up via sudo and it works fine. Notice how the bind address is different but the port (8888) is the same
This is pretty much a fresh install of Raspbian Lite 9 (Stretch) on a Pi Zero W.
The text was updated successfully, but these errors were encountered: