# systemd and sockets

## mv

As I understood, one of the main ideas of systemd is that "normally" you should not enable services like openssh or cups but instead only the corresponding socket service so that the corrseponding service is started once e.g. somebody connects to the ssh or cups port.

However, I realized that e.g. the first attempt to connect via ssh from outside always fails - only later works.

Similarly, the first print job seems to send rubbish (often the printer hangs afterwards).

I conjecture that the first byte (or packet or whatever) which is sent to the socket gets "eaten" by systemd. I would have expected that systemd is wired hard enough with the kernel to be able to read and "put back" the data.

Do others here experience the same problem or am I missing some kernel feature for this? (The only recommended feature which I do not have activated in the kernel is IPv6, but I doubt that this is related. Of course, e.g. I let cups.socket listen only to the ip4 local port.)

----------

## mbar

sshd socket works OK for me (it allows me to connect from outside), but not for cups -- maybe because I have to use hplip to print on my network printer.

----------

## mv

 *mbar wrote:*   

> sshd socket works OK for me (it allows me to connect from outside)

 

Thanks. So just to emphasize once more: After I attempted to connect once, it also works for me (which is not surprising since then the sshd daemon is running). Only the very first attempt to connect after boot (from outside or from inside) fails with "Connection reset by peer". Of course for sshd this is not a big issue, but apparently it is a big issue for cups.

BTW, unfortunately, I also have a printer which would require hplip, but in my case foo2zjs is sufficient.

However, in no case socket activation should be a problem since the idea in systemd is probably not that the first packet is lost or modified.

So I guess you are actually also suffering from the same bug. Probably this is yet another case where systemd does not hold what Poettering promised...

----------

## mbar

I just did a second test for cups socket and it worked  :Smile: 

I removed cups.service (disabled it) and enabled only cups socket and voila, printing works. So for me, sshd and cups work good configured as sockets.

I'm on ~amd64.

----------

## mv

 *mbar wrote:*   

> I removed cups.service (disabled it) and enabled only cups socket and voila, printing works. So for me, sshd and cups work good configured as sockets.

 

Thanks. So something must be missing in my configuration...

----------

