Skip to main content
1-Visitor
August 10, 2020
Question

Failed to transfer a file from remote TW server to local Ubuntu PC using C SDK

  • August 10, 2020
  • 1 reply
  • 2030 views

Hi,

I'm trying to get the file from remote TW server's SystemRepository to local file system, after calling all necessary C SDK v2.2.1 API functions:

twApi_Initialize(hostname, port, (char*)TW_URI, myPasswordCallback, NULL, MESSAGE_CHUNK_SIZE, MESSAGE_CHUNK_SIZE, (char)TRUE);

twApi_SetSelfSignedOk();
twApi_DisableCertValidation();

twApi_BindThing(thingName);

twcfg.file_xfer_staging_dir= (char*) "/home/davmel/stagingdir";

twFileManager_Create();

twFileManager_AddVirtualDir(thingName, (char*) "incoming", (char*) "/home/davmel/stagingdir/transfer/incoming");
twApi_Connect(CONNECT_TIMEOUT, twcfg.connect_retries);

 

Here all above calls return 0 error code.

But when I try here to get the remote file, I'm getting 1114 TW_GATEWAY_TIMEOUT error code. 

 

err = twFileManager_GetFile(systemRepo, "outgoing", sourceFile, thingName, "/incoming", targetFile, 40000, FALSE, &tid1);

 

The remote thing thingName is created as thing based on RemoteThingWithFileTransfer template. When I run my program I can see that this thing is connected. I have #define ENABLE_FILE_XFER 1 in my header file.

Please suggest what can be done to overcome this issue.

1 reply

22-Sapphire I
August 11, 2020

Just wondering how big is the file you are trying to transfer?

Also does the agent have all the proper permissions, I remember it sometimes needing to create a temporary staging folder when doing the transfer.

davmel1-VisitorAuthor
1-Visitor
August 11, 2020

The file is just 10 bytes. Not sure what kind of permissions do you mean, but for staging directory I have this:

twcfg.file_xfer_staging_dir= (char*) "/home/davmel/stagingdir";

Is there any other settings missed?

22-Sapphire I
August 11, 2020

basic CRUD for the Agent to be able to read/write/create/delete files in the staging folder (or even create subfolders)