cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

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

davmel
4-Participant

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

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.

5 REPLIES 5
PaiChung
22-Sapphire I
(To:davmel)

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.

davmel
4-Participant
(To:PaiChung)

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?

PaiChung
22-Sapphire I
(To:davmel)

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

davmel
4-Participant
(To:PaiChung)

The link that you provided brings me to my original post, please update it. Thanks.

davmel
4-Participant
(To:PaiChung)

I think that CRUD should be created by calling:

twFileManager_AddVirtualDir(thingName, (char*) "incoming", (char*) "/home/davmel/stagingdir/transfer/incoming");

Which already is done, but doesn't help to transfer the file.

Announcements