Service action sftp multiple connections problem

Hello Guru's!

I have a bit of a problem and I hope you guys can help me out.

Where are using an external SFTP server to store some files.

We build a service action to get the file by name from the SFTP server.

The SFTP server only allows 1 connection at the same time.

Here I have the problem because if I cal for example 10 times the get document service action from different places.

The SFTP server detects multiple connections and kicks them all.

Is there something to think of how to prevent this from happening?

Kind regards!

Rank: #221

Hi freek,

If your SFTP can have only one connection at same time, I would recommend you to do it via Timer.

A Timer is ready to run when the current time is greater or equal to the Timer runtime property NextRun .

When the Timer action ends successfully, the NextRun property of the Timer is updated to the next time that it should run. This time is computed according to the Schedule property of the Timer. (more info regarding timers here)

You can prepare the data before calling your timer to process (use the action Wake inside Timers tab):



Rank: #476

Hi Luis,

Thanks for your response!

For putting and deleting that would be a idea.

But what if I have a button in a screen to get a document.

And 10 users can see that button and click on it.

Should I fetch the document also by a timer?

Rank: #17

Hi Freek,

If there is only one connection possible at the time, you cannot have a solution where multiple users can directly access the FTP, as it will not guarantee that only one request is made at the time.

For that, you should let the user only make the request to get a document. Store the request details in an entity.

You can then use a timer, to process these requests one by one, store the document from the FTP server temporarily in another entity that the user can access to actually do the download.

Even if you would have multiple concurrent connections to the FTP, you could still reach the limit, as more requests can be made at the same time than what is allowed.



Rank: #2

As an additional solution, you could use a dedicated Entity with a single record that serves as a semaphore. Use the GetForUpdate Entity action, which ensures only 1 user gets access to a record, after that check whether it is set, if so do error handling (reporting to the user they can't use SFTP). If it's not set, set it (do an Update and Commit), do the SFTP, do another GetForUpdate and reset it. This ensures only one user can access SFTP, and no-one is blocked.

The only downside is that the flag in the Entity can get stuck if something goes wrong and it's not reset. So make sure you have some manual way to reset it.

Or you can just auto-retry the service action, a couple of time or until timeout,  in your button logic.

Rank: #2

Not sure what you mean? The problem is that if a second connection is attempted, all connections (including the first one) will be kicked by the remote host.