Skip to content

Datagram feature seems unreliable #2520

Open
@alexpacio

Description

@alexpacio

Hi all,

I am not sure if it's my own fault but I feel like there's something wrong with the datagram feature. I am using it on the latest 1.54.0 release in a Windows 11 host, using both the server and the client in the same host using the loopback interface for the connection.

When I send datagram using the mut from the server side like this:

if let Err(e) = handle_clone2.datagram_mut(|send: &mut Sender| send.send_datagram(chunk)) {
      error!("Error sending datagram: {:?}", e);
      break;
}

On the client side looks like I am only able to receive the chunks that I've sent where size is not above 1000 bytes.
Any other datagram being send by the Server is not received by the Client at all.
Instead, the reliable transport works correctly.

Here's how I am listening to them. FYI "writer" is a tokio's Simplex Writer half.

let (reader, mut writer) = simplex(&mtu * 16);
let _ = tokio::spawn(async move {
  loop {
      if !*running_clone4.lock().await {
          break;
      }

      let recv_result = handle_clone.datagram_mut(|recv: &mut Receiver| recv.recv_datagram());
  
      if let Err(e) = recv_result {
          eprintln!("Datagram receive error: {:?}", e);
          return;
      }

      if let Ok(Some(value)) = recv_result {
          if let Err(e) = writer.write_all(&value).await {
              eprintln!("Error writing datagram: {:?}", e);
              return;
          }
      }
  }
});

Here's how I init the entire thing:

let datagram_provider = Endpoint::builder()
    .with_send_capacity(200)
    .map_err(|e| TransportError::ConfigError(e.to_string()))?
    .with_recv_capacity(200)
    .map_err(|e| TransportError::ConfigError(e.to_string()))?
    .build()
    .unwrap();

// Start connection based on config
let handle = match &self.mode {
    QuicMode::Server { addr, cert_path, key_path } => {
        // Create a datagram provider that has a send queue capacity
        let addr_clone = addr.clone();
        let address: SocketAddr = addr_clone.parse()?;
        let io = s2n_quic::provider::io::Default::builder()
            .with_max_mtu(9001)?
            .with_receive_address(address)?
            .with_recv_buffer_size(12_000_000)?
            .with_send_buffer_size(12_000_000)?
            .build()?;
        let server = Server::builder()
            .with_tls((Path::new(cert_path), Path::new(key_path)))
            .map_err(|e| TransportError::Tls(e.to_string()))?
            .with_datagram(datagram_provider)
            .map_err(|e| TransportError::ConfigError(e.to_string()))?
            .with_io(io)
            .unwrap()
            .with_event(MtuEventInformer { mtu: self.mtu.clone() })
            .map_err(|e| TransportError::ConfigError(e.to_string()))?
            .start()
            .map_err(|e| TransportError::QuicStart(e))?;

Any help would be appreciated. Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions