torrust-tracker icon indicating copy to clipboard operation
torrust-tracker copied to clipboard

Error in demo UDP tracker logs: `failed to send`. Client's port is 0

Open josecelano opened this issue 7 months ago • 2 comments

I've seen a couple of errors like this in the tracker demo logs:

tracker  | 2025-04-14T08:52:42.491940Z  WARN process_request:send_response{client_socket_addr=*.*.*.*:0 response=Connect(ConnectResponse { transaction_id: TransactionId(I32(1163113452)), connection_id: ConnectionId(I64(8646890202544963935)) }) opt_req_kind=Some(Connect) req_processing_time=37.872µs}: torrust_udp_tracker_server::server::processor: failed to send bytes_count=16 error=Invalid argument (os error 22) payload=[0, 0, 0, 0, 69, 83, 179, 236, 119, 255, 236, 211, 118, 127, 129, 95]

The client's port is 0 (masked IP above).

The application logs the error when it tries to write the response:

let () = match self.send_packet(&client_socket_addr, payload).await {
    Ok(sent_bytes) => {
        if tracing::event_enabled!(Level::TRACE) {
            tracing::debug!(%bytes_count, %sent_bytes, ?payload, "sent {response_type}");
        } else {
            tracing::debug!(%bytes_count, %sent_bytes, "sent {response_type}");
        }

        if let Some(udp_server_stats_event_sender) =
            self.udp_tracker_server_container.udp_server_stats_event_sender.as_deref()
        {
            udp_server_stats_event_sender
                .send_event(Event::UdpResponseSent {
                    context: ConnectionContext::new(client_socket_addr, self.server_service_binding),
                    kind: udp_response_kind,
                    req_processing_time,
                })
                .await;
        }
    }
    Err(error) => tracing::warn!(%bytes_count, %error, ?payload, "failed to send"),
};

josecelano avatar Apr 14 '25 10:04 josecelano