oknozor / vessel

A selfhostable soulseek client
10 stars 1 forks source link

After issuing a search request vessel receive only PeerConnectionRequest from soulseek server #20

Open oknozor opened 3 years ago

oknozor commented 3 years ago

Reproduce :

  1. Start the server

    cargo run
  2. Send a GetPeerAddress message to the server

curl --request GET \
  --url http://localhost:3030/users/subnode/address
Jun 25 08:00:56.099  INFO vessel_server::tasks: Got http request GetPeerAddress("subnode")
Jun 25 08:00:56.099  INFO vessel_server::slsk::connection: Request sent to Soulseek server : GetPeerAddress("subnode")
Jun 25 08:00:56.272  INFO vessel_server::tasks: Got message from Server PeerAddress(PeerAddress { username: "subnode", ip: X.X.X.X, port: 63870, obfuscation: true, obfuscated_port: 2130706432 })

Everything works as expected so far : we send a peer address request and get a response from soulseek.

  1. Send a SearchRequest message to the server :
    curl --request GET \
    --url 'http://localhost:3030/search?term=%22Nirvana%22'

From this point we get a ton of incoming peer connection, advertising the search result, as expected.

Jun 25 08:05:48.985  INFO vessel_sse: SSE client connected
Jun 25 08:05:48.985  INFO api: 127.0.0.1:48532 "GET /events HTTP/1.1" 200 "http://localhost:5000/" "Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0" 483.834µs    
Jun 25 08:05:54.953  INFO vessel_server::tasks: Got http request FileSearch(SearchRequest { ticket: 1623088617, query: "nirvana" })
Jun 25 08:05:54.954  INFO vessel_server::slsk::connection: Request sent to Soulseek server : FileSearch(SearchRequest { ticket: 1623088617, query: "nirvana" })
Jun 25 08:05:55.248  INFO vessel_server::tasks: Got message from Server PeerConnectionRequest(PeerConnectionRequest { username: "badosu", connection_type: PeerToPeer, ip: X.X.X.X, port: 60099, token: 277243, privileged: false })
Jun 25 08:05:55.359  INFO vessel_server::tasks: Got message from Server PeerConnectionRequest(PeerConnectionRequest { username: "AnderMachines", connection_type: PeerToPeer, ip: X.X.X.X, port: 61546, token: 105162, privileged: false })
Jun 25 08:05:55.482  INFO vessel_server::tasks: Got message from Server PeerConnectionRequest(PeerConnectionRequest { username: "alkalinexandy", connection_type: PeerToPeer, ip: X.X.X.X, port: 61986, token: 308, privileged: false })
  1. Send a GetPeerAddress Message again :
Jun 25 08:08:09.563  INFO vessel_server::tasks: Got http request GetPeerAddress("subnode")
Jun 25 08:08:09.564  INFO vessel_server::slsk::connection: Request sent to Soulseek server : GetPeerAddress("subnode")

We still receive PeerConnectionRequest from server, so the thread is not blocked (or is it ?) and we are still reading from the tcp stream, but we don't get any other message than PeerConnectionRequest

Edit: This happens here : https://github.com/oknozor/vessel/blob/7c521204b6b7272c65e80659a03c944b1481bb06/vessel_server/src/tasks.rs#L71

When removing the following match arm, we receive messages correctly, even after sending a SearchRequest:

     ServerResponse:: PeerConnectionRequest(connection_request) => {
                                    let token = connection_request.token;

                                    peer_listener_tx
                                        .send(connection_request)
                                        .await
                                        .map_err(|err| eyre!("Error dispatching connection request with token {} to peer listener: {}", token, err))
                                }

I don't see why this keeps the message from being red, is it beacause something blocks or because we get out of the select clause and the stream buffer is red to the end ?

oknozor commented 3 years ago

Setting a higher channel bound seems to solve this, I am not closing it yet since it needs to be tested.