Enet4 / dicom-rs

Rust implementation of the DICOM standard
https://dicom-rs.github.io
Apache License 2.0
416 stars 81 forks source link

Very slow association with invalid adresses - Need to use custom timeout during connecting #483

Open qarmin opened 6 months ago

qarmin commented 6 months ago

Because this can be implemented, I am changing the discussion in the issue to make it more visible

Discussed in https://github.com/Enet4/dicom-rs/discussions/480

Originally posted by **qarmin** March 19, 2024 I have this code ``` debug!("Establishing association with '{}'...", &addr); let mut scu_opt = ClientAssociationOptions::new() .with_abstract_syntax(abstract_syntax) .called_ae_title(aetitle) .max_pdu_length(max_pdu_length); if !station_name.is_empty() { scu_opt = scu_opt.calling_ae_title(station_name); } let scu = scu_opt .establish_with(addr) .map_err(|_e| DicomError::CommonError(format!("Failed to establish connection with {addr}")))?; debug!("Association established"); Ok(scu) } ``` and after trying to connect to invalid address, after 2 minutes I have info, that dicom failed to establish connection. Can this be speed up? Can I use any workaround? ``` 11:29:01.681 [DEBUG] Establishing association with '192.168.10.124:4242'... 11:31:16.409 [ERROR] Failed to get patients from worklist: Failed to establish connection with 192.168.10.124:4242 ```
naterichman commented 2 months ago

Hi @qarmin can you see if #530 fixed your issue? You should be able to now do

    debug!("Establishing association with '{}'...", &addr);
    let mut scu_opt = ClientAssociationOptions::new()
        .with_abstract_syntax(abstract_syntax)
        .called_ae_title(aetitle)
        .read_timeout(20)
        .max_pdu_length(max_pdu_length);

By setting this, when you call establish it should return with an error after 20s.