Skip to content
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

Unix sockets are not implemented #134

Closed
guineawheek opened this issue Apr 11, 2016 · 14 comments
Closed

Unix sockets are not implemented #134

guineawheek opened this issue Apr 11, 2016 · 14 comments

Comments

@guineawheek
Copy link

socket() works, but bind() doesn't create the actual socket file.
This kills things like wine and ssh-agent.

@SvenGroot
Copy link
Member

Unix sockets are partially implemented, and they do work. The socket files just don't show up in the file system. However, it's still possible to connect to them if you know the path of the socket file. Of course, this does break applications that attempt to "stat" a socket file or do anything else that depends on the file being present.

We're working to address this issue.

@sunilmut
Copy link
Member

As @SvenGroot mentions, file system integration of UNIX sockets is not complete yet. We will be tracking\prioritizing which features to light up next by looking at the feedback provided at the wpdev portal. We appreciate your feedback and please make sure to provide it through the wpdev portal as well.

@MadcowD
Copy link

MadcowD commented May 1, 2016

@SvenGroot @sunilmut Just an update I can reproduce the issue referenced with #1331. Jupyter notebook is using sockets and getting Invalid argument (src/tcp_address.cpp:186). Further investigation led me to find that
libzmq is not currently working with BashOnWindows.

I built libzmq and got the following log from the test suite. All of the errors point to the same line of code.
test-suite.txt
In particular, this is the code which is causing an invalid argument error. See getifaddrs.

#elif ((defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_FREEBSD ||\
    defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_OPENBSD ||\
    defined ZMQ_HAVE_QNXNTO || defined ZMQ_HAVE_NETBSD ||\
    defined ZMQ_HAVE_DRAGONFLY || defined ZMQ_HAVE_GNU)\
    && defined ZMQ_HAVE_IFADDRS)

#include <ifaddrs.h>

//  On these platforms, network interface name can be queried
//  using getifaddrs function.
int zmq::tcp_address_t::resolve_nic_name (const char *nic_, bool ipv6_, bool is_src_)
{
    //  Get the addresses.
    ifaddrs *ifa = NULL;
    const int rc = getifaddrs (&ifa);
    errno_assert (rc == 0);
    zmq_assert (ifa != NULL);

    //  Find the corresponding network interface.
    bool found = false;
    for (ifaddrs *ifp = ifa; ifp != NULL; ifp = ifp->ifa_next) {
        if (ifp->ifa_addr == NULL)
            continue;

        const int family = ifp->ifa_addr->sa_family;
        if ((family == AF_INET || (ipv6_ && family == AF_INET6))
        && !strcmp (nic_, ifp->ifa_name)) {
            if (is_src_)
                memcpy (&source_address, ifp->ifa_addr,
                        (family == AF_INET) ? sizeof (struct sockaddr_in)
                                            : sizeof (struct sockaddr_in6));
            else
                memcpy (&address, ifp->ifa_addr,
                        (family == AF_INET) ? sizeof (struct sockaddr_in)
                                            : sizeof (struct sockaddr_in6));
            found = true;
            break;
        }
    }

    //  Clean-up;
    freeifaddrs (ifa);

    if (!found) {
        errno = ENODEV;
        return -1;
    }
    return 0;
}

Related #69

@benhillis
Copy link
Member

Adding link to source code exhibiting an issue: #207

@lypanov
Copy link

lypanov commented Nov 10, 2016

This AFAICT also breaks Rails 5 out of the box without the hack of disabling of spring (it's simply too slow at times without Spring so this is really painful). Any news on this?

@mindplay-dk
Copy link

This may be what's breaking the default socket-based configuration with NGINX and PHP-FPM? I was able to get it to run reliably only after configuring it to use TCP instead of sockets, and also failed to use sockets with PHP, is this all related to this issue?

Is there a fix on the way, or is this very far off? I really want to use UOW for development on my Windows system, mainly because there are features (such as sockets, threads and readline support) that are unavailable in Windows-builds of PHP.

@aseering
Copy link
Contributor

Could someone on the WSL team perhaps summarize what they believe to be the status of this issue?

I have personally used UNIX Sockets without any issue. But I haven't done anything fancy with them. I realize it's more complicated than a simple "works" vs "not works" -- there are lots of flags and options and whatnot that you can set on a socket that affect its behavior; my understanding is that some work and some do not.

@sunilmut
Copy link
Member

@aseering - We are not aware of any open issues with the WSL AF_UNIX socket implementation. But, I know it's not fully compatible yet because for example the dbus test does not give the same results as that of native Ubuntu. We haven't dug into all the failures yet. We are trying to prioritize issues reported here as they come.

@mindplay-dk - Thanks for your post. We will have to take one issue at a time, so that we can root cause and fix it. Can you please post repro steps, build number and strace, if possible? You can see the template here. To gather strace, use strace -o <trace_file> -ff <cmd>

@aseering
Copy link
Contributor

aseering commented Apr 10, 2017

Regarding capturing an strace, the challenge here will presumably be identifying what command to run. (The "command" in this case is two separate backgrounded system services, nginx and php-fpm; both would need to be run directly and in the foreground.) @mindplay-dk -- I think you indicated on #1851 that you weren't sure how to accomplish that level of Linux magic? I can try to take a look, but I may not get to it for a while. If anyone else is following this thread and would be willing to give it a shot, please do.

@aseering
Copy link
Contributor

@sunilmut -- thanks! The title of this ticket implies that UNIX sockets don't work at all. And the ticket is still open. Up to you, but I wonder if some ticket-wrangling might be in order? :-)

@sunilmut
Copy link
Member

@aseering - Makes sense. I will close this issue out, it's too broad and not actionable. @mindplay-dk - We will continue to work with you on the other issue.

As for the strace, we would have to then rely on the repro.

@mindplay-dk
Copy link

@sunilmut I know you closed this issue, but not sure where else to answer the questions you asked. (?)

To help you repeat the php-pm issue, here's the sandbox project for testing:

https://bitbucket.org/mindplaydk/http-bench

This project has a bunch of different scripts that all do the same thing - return a JPEG image - in different ways, because I'm using it to benchmark and evaluate the performance of various means of sending an image.

Clone the project locally.

Run composer install and you should be all set.

Run vendor/bin/ppm from the project root folder to launch.

The relevant changes for the php-pm setup happened in this commit and the only thing I wrote really was this simple front controller which does nothing except return the image, it doesn't even care what the Request looks like at all. Quick and dirty.

I posted steps to recreate my environment here.

I'm on Windows 10 Pro version 1703 build 15063.13

I tried to run that "strace" you asked for, so, this:

strace -o ./strace -ff vendor/bin/ppm start

It produced these files.

I think that's everything you asked for - let me know if there's anything else I can do?

@mindplay-dk
Copy link

(oh, and I guess composer install worked on my system because it's in the path on my Windows system already and the phar file works with the Linux installation of PHP as well. If you don't have Composer installed, you may need to do that first.)

@0x4248
Copy link

0x4248 commented Jan 25, 2021

im getting a Socket type not supported when i use tcpdump anyone help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants