Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to get uwsgi and nginx to play nice. After moving to "file sockets" (hopefully I'm using the right terminology here) from TCP sockets, the only thing I get from uwsgi is a 400 with no helpful logging info. I'd like to inspect what exactly nginx is sending uwsgi. How do I do that? Everything I've read so far about bash and sockets relates to TCP or UDP connections.

My assumption is that nginx is unable to write to the file socket at all or at least properly, so I'd like to "inspect" the file socket to see what, if anything, is being written there.

Ideally I'd like a tail -f equivalent to point at the socket file.

If this assumption wasn't correct that would mean either my browser is sending a malformed request (HIGHLY unlikely IMO, using Chrome) OR uwsgi is incorrectly reporting the nature of the error OR I'm misunderstanding the meaning of an HTTP 400 error. Are any of these a possible cause of the problem?

share|improve this question

2 Answers 2

moving to "file sockets" (hopefully I'm using the right terminology here)

Sometimes unix sockets are referred to this way, but it's a bit of a misnomer and maybe has led you to a misconception here. Unix sockets are addressed using the file system, but they aren't real files, meaning:

I'd like to "inspect" the file socket to see what, if anything, is being written there. Ideally I'd like a tail -f equivalent to point at the socket file.

There isn't anything being written there, if by "there" we mean disk storage. It's a normal socket in the sense that what gets written there is held in memory by the OS until read.

Unfortunately, it's not a normal socket in that it doesn't use a network interface (that's why the "address" is a file path), so you can't watch what's going on by eavesdropping on any particular interface (including local loopback), with e.g. wireshark or tcpdump.

So, I don't have a complete solution to your problem, but hopefully this will help you proceed in the right direction. I did a bit of searching and turned up this S.U. Q&A, which implies you can accomplish an eavedropping effect by using two sockets with a relay in the middle.

share|improve this answer

The socket file is a rendezvous point, not a storage area. You can't do something like tail -f, because tail -f reads data as it's being stored, and nothing is being stored.

If you want to know what data is transiting through the socket, trace what one of the processes is doing. Use strace and trace at least the sendmsg and recvmsg system calls.

Before you do that, though, see if you can tell what's going on from either server's logs. Set up nginx for debugging to get more verbose logs. Check your server's configuration to see where the log files are located, and increase the logging level if desired. Check where the uwsgi logs are as well.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.