FDH2 / UxPlay

AirPlay Unix mirroring server
GNU General Public License v3.0
1.35k stars 72 forks source link

When use `-p`, only first connection works, if stop mirroring from client, no mirroring window for subsequent connections #91

Closed azuwis closed 2 years ago

azuwis commented 2 years ago

Server: uxplay 1.50, client: iPad 8, iOS 15.3.1

Start uxplay:

$ uxplay -vd vah264dec -p
using network ports UDP 7011 6001 6000 TCP 7100 7000 7001
using system MAC address xx:xx:xx:xx:xx:xx
Initialized server socket(s)
$ netstat -tuanp | grep uxplay
tcp        0      0 0.0.0.0:7000            0.0.0.0:*               LISTEN      976321/uxplay 

Client connects 1st time, everything works:

Accepted IPv4 client on socket 28
Local: 192.168.2.25
Remote: 192.168.2.16
Open connections: 1
Client identified as User-Agent: AirPlay/605.1
Accepted IPv4 client on socket 30
Local: 192.168.2.25
Remote: 192.168.2.16
Open connections: 2
raop_rtp_mirror starting mirroring
Begin streaming to GStreamer video pipeline
$ netstat -tuanp | grep uxplay            
tcp        0      0 0.0.0.0:7100            0.0.0.0:*               LISTEN      977132/uxplay       
tcp        0      0 0.0.0.0:7000            0.0.0.0:*               LISTEN      977132/uxplay       
tcp        0      0 192.168.2.25:7100      192.168.2.16:63288     ESTABLISHED 977132/uxplay       
tcp        0      0 192.168.2.25:7000      192.168.2.16:63286     ESTABLISHED 977132/uxplay       
tcp        0      0 192.168.2.25:7000      192.168.2.16:63287     ESTABLISHED 977132/uxplay       
udp        0      0 0.0.0.0:7011            0.0.0.0:*                           977132/uxplay

Stops mirroring from client:

raop_rtp_mirror tcp socket is closed, connection ended
Connection closed for socket 28
Destroying connection
Open connections: 1
Connection closed for socket 30
Destroying connection
Open connections: 0

Netstat shows 7100 port remains listening:

$ netstat -tuanp | grep uxplay
tcp        0      0 0.0.0.0:7100            0.0.0.0:*               LISTEN      977132/uxplay       
tcp        0      0 0.0.0.0:7000            0.0.0.0:*               LISTEN      977132/uxplay

Client connects 2nd time, no mirror window shows up, raop_rtp_mirror initializing sockets failed:

Accepted IPv4 client on socket 28
Local: 192.168.2.25
Remote: 192.168.2.16
Open connections: 1
Client identified as User-Agent: AirPlay/605.1
Accepted IPv4 client on socket 30
Local: 192.168.2.25
Remote: 192.168.2.16
Open connections: 2
raop_rtp_mirror starting mirroring
raop_rtp_mirror initializing sockets failed

Netstat shows no 7100 ESTABLISHED tcp connection:

$ netstat -tuanp | grep uxplay
tcp        1      0 0.0.0.0:7100            0.0.0.0:*               LISTEN      977132/uxplay       
tcp        0      0 0.0.0.0:7000            0.0.0.0:*               LISTEN      977132/uxplay       
tcp        0      0 192.168.2.25:7000      192.168.2.16:63297     ESTABLISHED 977132/uxplay       
tcp        0      0 192.168.2.25:7000      192.168.2.16:63296     ESTABLISHED 977132/uxplay       
udp        0      0 0.0.0.0:7011            0.0.0.0:*                           977132/uxplay

Note: if stop mirroring from server (close mirroring window), 7100 listening port will dispear, mirroring again will work as expected.

fduncanh commented 2 years ago

OK I've reproduced this with 1.50. is it a regression?

EDIT: Yes, 1.49 behaves OK. I will see what has done this. EDIT: sorry 1.49 is broken too.

azuwis commented 2 years ago

For me, 1.50/1.49/1.48 all have this problem, 1.47 works fine.

I'll try git bisect to find the commit.

azuwis commented 2 years ago

5efcf019bd647b68ab9ec06b252ca50db53be280 is the first bad commit commit 5efcf019bd647b68ab9ec06b252ca50db53be280 Author: fduncanh fduncanh@gmail.com Date: Sat Mar 12 03:14:09 2022 -0500

fix historic bug whene socket closes

lib/raop_rtp_mirror.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)

fduncanh commented 2 years ago

I suspected it ..... its relevant to the issue! Thanks!

fduncanh commented 2 years ago

that change has been reverted. thanks for your help!