Hot answers tagged

43

Altough in the time, when the question was asked, it was really impossible, but it is possible nowadays. You can to both: UNIX=>TCP and UNIX=>UNIX forwarding. For example: ssh \ -R/var/run/mysql.sock:/var/run/mysql.sock \ -R127.0.0.1:3306:/var/run/mysql.sock \ somehost It is possible since OpenSSH 6.7.


40

Use Rewrite conditions to match for this special case: RewriteEngine On RewriteCond %{REQUEST_URI} ^/socket.io [NC] RewriteCond %{QUERY_STRING} transport=websocket [NC] RewriteRule /(.*) ws://localhost:8082/$1 [P,L] ProxyPass /socket.io http://localhost:8082/socket.io ProxyPassReverse /socket.io http://localhost:8082/socket....


28

Only answering the service restart part. I came across Monit as well, but on CentOS 7 systemd takes care of all that for you. You just need to add these two lines to the .service file (if they're not there already): Restart=always RestartSec=3 See https://jonarcher.info/2015/08/ensure-systemd-services-restart-on-failure/ for reference. If you want to ...


23

When you specify host=localhost, mysql client will try to login to mysql server using unix named pipe which requires a .sock file. This can be bypassed by specifying host=127.0.0.1. This will make mysql client use TCP to connect to the server. Taken from MySQL's documentation: mysql --host=127.0.0.1 --port=3306 --user=your_uname --password=your_pass


22

You can use socat to export your unix socket as TCP socket. Here is the command to do so: socat TCP-LISTEN:12345 UNIX-CONNECT:/var/program/program.cmd This will create TCP socket listening on port 12345 which will connect to mentioned unix socket of your program. For the deletion issue, I did not test it myself. You can verify it and tell us about it :) ...


21

Well, it's simple. Socket is a file based communication, and you can't access the socket from another machine. On the other hand, ports are open to the world (depends on configuration) and you can access the mysql from other machine using host+port combination. Also, as much I understand sockets, they are just combination of host+port, just in the file ...


20

What's the difference between Unix socket and TCP/IP socket? A TCP/IP socket is used for communication across TCP/IP networks. A connected TCP socket is identified by the combination of local IP, local port, remote IP and remote port. A listening TCP socket is identified by local port and possibly local IP. AIUI at least on linux TCP/IP sockets always ...


17

A terribly written question, but the term I was looking for was reverse proxy. Basically, just like how nginx can forward different request to several instances of the web app based on the path or hostname, it can also be configured to "forward" the request to a websocket server instance. e.g.: location /socket { proxy_pass http://websocket; ...


16

Solution As I said in the first sentence, I already found the solution: I rebuilt the libapr1 package inside the guest. I found the solution by googling for "Invalid argument: alloc_listener: failed to get a socket for (null)", the 5th hit was Invalid argument crap which mentions the kernel upgrade and refers to another blogger talking about Fedora 11 ...


16

You can try to use the iftop command. It provides a nice curses display. This can show realtime and average statistics for an interface or specific source/destination/port. It can can also filter, but I haven't explored that functionality. Host display: General: n - toggle DNS host resolution P - pause display s - toggle ...


15

Actually, ss from iproute2 (replacement for netstat, ifconfig, etc.) can show this information. Here is an example showing an ssh-agent unix domain socket to which a ssh process has connected: $ sudo ss -a --unix -p Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port u_str ESTAB 0 0 /...


15

Short answer: Yes, since version 1.5. Let's have a look at server keyword arguments documentation: <address> is the IPv4 or IPv6 address of the server. Alternatively, a resolvable hostname is supported, but this name will be resolved during start-up. Address "0.0.0.0" or "*" has a special meaning. It indicates that the ...


15

One thing you might check is (which requires you to login to the MySQL console) - check to make sure that you have permissions to login to root via localhost. mysql -h 127.0.0.1 -u root -p -- Once you have successfully logged in -- mysql> select user,host from mysql.user; +------+--------------------------------+ | user | host ...


15

Run mysqld --help and check, if it reports any problems with config Check logs in /var/log/mysql Try runnig it directly and check errors: mkdir /var/run/mysqld/ chown mysql: /var/run/mysqld/ mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --socket=/var/run/mysqld/mysqld.sock


13

You may find that just setting the socket path doesn't work. Memcached drops privileges before it creates its socket, though after it's written its PID. It's common to put the socket in /var/run (e.g. as mysql does), but only root can write there, so create /var/run/memcached and chown it to nobody, then set /var/run/memcached/memcached.sock as the socket ...


12

Its now 2015 and I assume the kernel patch the Michael mentions has now made it's way into the stable kernel. I have a working example of 2 docker containers one with php-fpm and the other with nginx talking to each other via a unix socket. See: https://github.com/brad-jones/conductor/tree/master/example-project The key to it working though was to open up ...


11

You can use python: python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/tmp/test.sock')" Also C, see this answer.


11

Yes, you can do this. All you need is systemtap. Consider one of the example systemtap scripts which will print the PID and process name of any program that reads or writes a specified inode (and your Unix domain socket is just such a thing). You can trivially modify this script to print the actual data being read/written; I'll leave doing so as an ...


11

Yes, this is a valid way to check that the socket is non-blocking. The value for a non-blocking socket is 04000, non-blocking sockets in /proc/<pid>/fdinfo are represented in octal. You can validate this behaviour with python. Python 2.7.5 (default, Feb 19 2014, 13:47:28) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2 Type "help", "copyright", "...


11

Note to future travelers: It depends on your specific configuration but this is very likely an issue with apparmor. If you don't want to disable locking take a look at syslog and see if you're getting apparmor denies on that file. You'll see something like: apparmor="DENIED" operation="open" parent=29871 profile="/usr/sbin/mysqld" name="/run/mysqld/mysqld....


10

This can happen because of just about any piece of software that incorrectly holds network buffers without releasing them. It just happened to me in Win7 64bit. Chrome and Firefox stopped being able to connect to any web pages, windows file sharing stopped working, and WinSCP and PuTTY both gave errors that included the words No buffer space available. ...


10

To solve this problem for myself, I had to adjust the OS "ulimit" setting: ulimit -a -- Check current setting ulimit -n 10000 -- Edit setting value Source: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=595527


9

Let's look into source code, as it's the best documentation in the world of open source. net/ipv4/tcp_diag.c: if (sk->sk_state == TCP_LISTEN) { r->idiag_rqueue = sk->sk_ack_backlog; r->idiag_wqueue = sk->sk_max_ack_backlog; } else { r->idiag_rqueue = max_t(int, tp->rcv_nxt - tp->copied_seq, 0); r->idiag_wqueue ...


9

You can communicate the host machine or even two containers using the same socket. In the general case of two containers, you should start the two dockers from the host machine sharing a volume that should be created in the host machine. docker run --name "containerA" -v /var/run/common_socket_dir:/var/run/common_socket_dir... docker run --name "containerB"...


8

I wrote a tool which uses MvG's gdb method to reliably get socket peer information, kernel debug symbols not needed. To get the process connected to a given socket, pass it the inode number: # socket_peer 1013410 3703 thunderbird To find out for all processes at once use netstat_unix, it adds a column to netstat's output: # netstat_unix Proto RefCnt ...


8

In my case, running mysqld_safe created a new mysqld.sock file. $ cd /etc/init.d/ $ mysqld_safe You'll probably won't get prompt back, but if you restart your session, a mysqld.sock file will be somewhere. Find it with $ sudo find / -type s | grep mysqld.sock


8

netstat -an | grep ESTABLISHED | wc -l This will count all opened sockets in the system and will output just the total. You can of course also change ESTABLISHED for whatever you need, for example a port or a communication status like CONNECTED or LISTENING.


8

Most MySQL clients are odd in the fact that if you specify the host as localhost, they alias that to a socket connection instead of a TCP connection. Your options are to either stick with 127.0.0.1 or, if the client supports it (like the mysql CLI binary does with the --protocol flag), force it to use TCP instead of a unix socket.


8

how can I check the maximum permitted length of a path of a Unix domain socket, on a Linux On Linux, this length is usually defined as 108. It is defined by the UNIX_PATH_MAX variable in the /usr/include/linux/un.h header file : cat /usr/include/linux/un.h | grep "define UNIX_PATH_MAX" #define UNIX_PATH_MAX 108 You could find further info here : ...


8

You will need to set the socket file in spool dir of postfix, e.g: /var/spool/postfix/var/run/opendkim After changing that, you might see problem about permission, then just change group owner of that dir to postfix and it will work. See https://unix.stackexchange.com/a/74491/22454


Only top voted, non community-wiki answers of a minimum length are eligible