RC (telnet) interface and CLOSE_WAIT

*nix specific usage questions
jeffiel
New Cone
New Cone
Posts: 5
Joined: 25 Aug 2006 00:12

RC (telnet) interface and CLOSE_WAIT

Postby jeffiel » 19 Dec 2006 00:33

I have a PHP class which acts as an abstration for a VLC process, defined by a host and a port for RC control. You can see the PHP code below... but in essence it connects to the port, issues the command, reads a line of response, then closes the connection.

The problem I'm having is that VLC ends up with many connections in a CLOSE_WAIT state, and a positive RECV buffer (according to netstat). Because the RC interface is limited to a single simultaneous connection, the instance is, at this point, hung until restart... presumably waiting for a FIN from the client, which has already disconnected.

I'm using the rc "logout" command so that vlc should initiates the close, but CLOSE_WAIT shouldn't be reached in that case.

I'm not sure how I get into this state, so if anybody has any advice to offer, I'm all ears. Thanks.

Code: Select all

// connect if(FALSE === ($this->Sock = @fsockopen($this->Host, $this->Port, $errno, $errStr, 3))) throw(new Exception("Could not connect to host {$this->Host} at port {$this->Port} error: $errStr ($errNo)")); // short timeout stream_set_timeout($this->Sock, 3); // send command if(FALSE === fwrite($this->Sock, "$command\n")) throw(new Exception("Write fail: $command")); // sleep sleep(0.25); // read response (shoudl probably be done with a select, instead of a sleep and read) $response = fgets($this->Sock); // clean logougt if(FALSE === fwrite($this->Sock, "logout\n")) throw(new Exception("Write fail: logout")); // close down if(!@fclose($this->Sock)) throw(new Exception("Unclean close of sock"));

jeffiel
New Cone
New Cone
Posts: 5
Joined: 25 Aug 2006 00:12

Postby jeffiel » 19 Dec 2006 00:44

netstat output:
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49711 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49710 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49708 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49727 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49726 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49725 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49724 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49723 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49722 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49721 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49720 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49719 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49718 CLOSE_WAIT
tcp 20 0 localhost.localdomain:3994 localhost.localdomain:49717 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49716 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49715 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49743 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49742 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49741 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49740 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49739 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49737 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49735 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49734 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49730 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49729 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49728 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49753 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49752 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49751 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49750 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49749 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49748 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49747 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49746 CLOSE_WAIT
tcp 14 0 localhost.localdomain:3994 localhost.localdomain:49745 CLOSE_WAIT
tcp 53 0 localhost.localdomain:3994 localhost.localdomain:49744 CLOSE_WAIT

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Postby Rémi Denis-Courmont » 04 Jan 2007 19:40

Using RC over TCP is a big bad kludge. You should try to use the telnet interface, or the HTTP interface. It that is not suitable, use the RC interface with a unix sockets (or a pipe) and handle the TCP server side yourself.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

jeffiel
New Cone
New Cone
Posts: 5
Joined: 25 Aug 2006 00:12

Postby jeffiel » 04 Jan 2007 20:48

That's what I was afraid of. Thanks for the info.


Return to “VLC media player for Linux and friends Troubleshooting”

Who is online

Users browsing this forum: No registered users and 17 guests