Aspera

 View Only
  • 1.  Transfer SDK Download hanging if file not found

    Posted Fri April 07, 2023 05:21 PM

    Hi,

    I have a Java client that is using the Transfer SDK and Aspera Daemon to download files from cloud object storage.  If the file exists  the download completes without issue.  If however the file does not exist the operation hangs forever.  I see the "file not found" error when looking thru the daemon logs but it's never communicated back to the client.  The last status the client sees is SESSION_START and RUNNING but no errors.

    Any ideas? 

    thanks :)

    Chris



    ------------------------------
    Christopher LoGiudice
    ------------------------------


  • 2.  RE: Transfer SDK Download hanging if file not found

    Posted Tue April 11, 2023 04:37 PM

    Hi,

    It may be worth opening a support case to review logs and troubleshoot in more detail. I tried one of the samples with an invalid filename to download and the client does terminate. 

    The asperatransferd logs show that it is receiving the session error and it is sending it back to the listener that is waiting on session updates. It seems from your descrption that you are seeing at least the first message with 'Server aborted session: No such file or directory'? Are you also a similar set of messages to the ones below?

    message: "{\"Loss\":0,\"Code\":43,\"Description\":\"Server aborted session: No such file or directory\",\"SessionId\":\"8b99ae3c-1f8b-41dc-b077-e530d76332bf\",\"UserStr\":\"a57b9d05-1a66-4557-b00b-49c5f25bdf50_s_bbe23bbd-07df-479b-96ca-abdd08f901ae\"}"
    {"appname":"faspmanagerd","hostname":"127.0.0.1","level":"error","msg":"Error: (Session [Session [id=bbe23bbd-07df-479b-96ca-abdd08f901ae transferid=a57b9d05-1a66-4557-b00b-49c5f25bdf50 state=Running]] no stderr on failure) caught error (exit status 1) ","time":"2023-04-10T20:34:30-07:00"}
    {"appname":"faspmanagerd","hostname":"127.0.0.1","level":"info","msg":"Info: TransferWorker:runOrder execution for (xfer=a57b9d05-1a66-4557-b00b-49c5f25bdf50 session=bbe23bbd-07df-479b-96ca-abdd08f901ae) completed (exit status 1)","time":"2023-04-10T20:34:30-07:00"}
    {"appname":"faspmanagerd","hostname":"127.0.0.1","level":"info","msg":"Info: Session [Session [id=bbe23bbd-07df-479b-96ca-abdd08f901ae transferid=a57b9d05-1a66-4557-b00b-49c5f25bdf50 state=Failed]] state changed Failed","time":"2023-04-10T20:34:34-07:00"}
    {"appname":"faspmanagerd","hostname":"127.0.0.1","level":"info","msg":"Info: message loop terminated for transfer id=a57b9d05-1a66-4557-b00b-49c5f25bdf50","time":"2023-04-10T20:34:34-07:00"}
    {"appname":"faspmanagerd","hostname":"127.0.0.1","level":"info","msg":"Info: EventManager: done notifying 1 listener(s) about event (model.TransferResponse{ApiVersion:\"\", TransferId:\"a57b9d05-1a66-4557-b00b-49c5f25bdf50\", Title:\"strategic\", TransferType:1, Status:\"FAILED\",...


    The other question would be where is the client hung or waiting forever, is it in the iterator created by `client.monitorTransfers`? 



    ------------------------------
    Jose Gomez
    ------------------------------



  • 3.  RE: Transfer SDK Download hanging if file not found

    Posted Tue April 11, 2023 06:56 PM

    Thank you for the response Jose!  I am seeing those same messages in the daemon logs.

    I based my code off of the examples so I would think it looks similar to yours.  Can you tell me if anything stands out to you?

            TransferServiceGrpc.TransferServiceBlockingStub client = TransferServiceGrpc.newBlockingStub(
                    ManagedChannelBuilder.forAddress("localhost", 55002).usePlaintext().build());

              
            Transfer.StartTransferResponse transferResponse = client.startTransfer(Transfer.TransferRequest.newBuilder()
                    .setTransferType(Transfer.TransferType.FILE_REGULAR)
                    .setConfig(Transfer.TransferConfig.newBuilder().build())
                    .setTransferSpec(transferSpec)
                    .build());

            Iterator<Transfer.TransferResponse> monitorTransferResponse = client.monitorTransfers(
                    Transfer.RegistrationRequest.newBuilder()
                            .addTransferId(transferId)
                            .addFilters(Transfer.RegistrationFilter.newBuilder()
                                    .setOperator(Transfer.RegistrationFilterOperator.OR)
                                    .build())
                            .build());

            for (Transfer.TransferResponse info = monitorTransferResponse.next();
            monitorTransferResponse.hasNext();
            info = monitorTransferResponse.next())
            {
                if (info.getStatus() == Transfer.TransferStatus.FAILED ||
                    info.getStatus() == Transfer.TransferStatus.COMPLETED ||
                    info.getTransferEvent() == Transfer.TransferEvent.FILE_STOP)
                {
                    System.out.println("download finished ");
                    break;
                }

            }



    ------------------------------
    Christopher LoGiudice
    ------------------------------



  • 4.  RE: Transfer SDK Download hanging if file not found

    Posted Wed April 12, 2023 01:21 AM

    Hi Christopher,

    I didn't try the java sample code yesterday actually, I had a python sample handy and tried with that. I have built the java FileRegularDownloadExample.java sample and I see the issue. The program gets the transfer event SESSION_START and it seems it never gets the session error event.

    I think there is probably a subtle bug with the loop in that it is not processing event n until event n + 1 has arrived. In a successful transfer it will receive a FILE_STOP event and then a COMPLETED, so it exits the loop when the FILE_STOP even is received and never processes the COMPLETED event. In a failed transfer there is no FILE_STOP, so it doesn't happen to work by accident. And changing the logic to avoid the break if there is a TRANSFER_STOP makes the program also hang even with a successful download of a file.

    Changing the loop to the following works in both cases:

            // monitor transfer until it finishes
            //
            while (monitorTransferResponse.hasNext()) {
                Transfer.TransferResponse info = monitorTransferResponse.next();
                System.out.println("transfer info " + info);
                System.out.println("file info " + info.getFileInfo());
                System.out.println("transfer event " + info.getTransferEvent());

                if (info.getStatus() == Transfer.TransferStatus.FAILED ||
                        info.getStatus() == Transfer.TransferStatus.COMPLETED) {
                    System.out.println("download finished " + info.getStatus().toString());
                    break;
                }
            }

    I have also removed the check on FILE_STOP since it may terminate things early if you are planning to download multiple files. In that case there would be a FILE_STOP event generated for each of the files downloaded by the transfer.

    Hopefully this works for you. I'll create an internal ticket to fix the loop in the java samples for the next transfer sdk update.

    Thanks for reporting the problem!



    ------------------------------
    Jose Gomez
    ------------------------------



  • 5.  RE: Transfer SDK Download hanging if file not found

    Posted Wed April 12, 2023 10:42 AM

    Fantastic!  Thank you Jose!  All good now :)



    ------------------------------
    Christopher LoGiudice
    ------------------------------