API 1 FTPS with MBS CURLSMBS

I finally managed to get the accounting software company to set up FTPS, however now I have the following problem, see test code below
var cmbs as new CURLSMBS
// s is a string parameter when calling the method with windowsansi encoding
var i as integer
if not DebugBuild then

var fwp as new XojoCloud.FirewallPort(990,xojocloud.FirewallPort.Direction.Outgoing)
fwp.open
if fwp.isopen then

// get following from Grunndata
cmbs.OptionURL=ftpaddress
cmbs.OptionUsername=ftpuser
cmbs.OptionPassword=ftppass

cmbs.SetInputData(s)
cmbs.OptionAppend=true
cmbs.OptionUpload=true
//cmbs.OptionLocalPortRange=2
cmbs.OptionPort=990
//cmbs.OptionTransferText=True
var i as integer =cmbs.Perform
if i <> 0 then
  MsgBox (cmbs.DebugData+endofline)
  return
end if
var bb as boolean
MsgBox (cmbs.DebugData)

else

end if

else
// get following from Grunndata
cmbs.OptionURL=ftpaddress
cmbs.OptionUsername=ftpuser
cmbs.OptionPassword=ftppass
cmbs.SetInputData(s)
cmbs.OptionAppend=true
cmbs.OptionUpload=true
cmbs.OptionTransferText=True

cmbs.OptionPort=990
i =cmbs.Perform
MsgBox (cmbs.DebugData)
var bb as boolean

end if

My problem is the OptionTransferText. If I use that on XojoCloud the app just shuts down.
I know the FTPS server accepts the data because it works when I debug locally - that is to say the data arrives and is written to the FTPS Server.
If I just send withoutthe option defined then the text arrives as UTF8 and their import routine requires windowsansiā€¦ Note I do send as windowsansi

Are you sure itā€™s FTPS and not FTPS?

Any crash reports seen?
For FTP you may need two ports, so 990 plus some other one.

Christian,
Yes itā€™s FTPS. As I said it runs fine locally on my developer machine.
Maybe a stupid question but where would I find a crash report on XojoCloud. All I get in the browser is

Screen Shot 2021-02-22 at 14.12.06

It just ran twice and then stalled the third time, so it seems to function intermittently

You may ask @Jason_Parsley or hello@xojo.com for support on crash reports.

SFTP needs only one port.
FTPS needs two ports, one data and one command connection.
And you may need to use OptionFTPPort to tell the server what port you opened for data connection.

1 Like

Christian,
thanks that seems to have done the trick.
I opened port 991 as well
set OptionFTPPort="-:990-991"
and so far everything works.
If ever I come back up to Koblenz Iā€™ll make sure to bring another box of wine

1 Like

Let me know when you are in the area.

Actually that didnā€™t fix itā€¦ Iā€™ll take a break on this and come back to it later. Iā€™ll still bring the wine if ever :wink:

This isnā€™t going to work if your transfer code is asynchronous because when fwp goes out of scope, the port will close.

I suggest putting an array of FirewallPorts somewhere and storing references to them until you are sure you are done with them.

1 Like

Hi Greg,
Thanks.
I tried an array, but in the method. Iā€™ll make it a property of the webpage and see if that does the trick.

If youā€™re using them a lot, just put them on App and open them when the app launches. Thatā€™ll save you a lot of headaches.

Ok, I have opened 100 outgoing ports (65000 to 65100)
I get a connection on 990 and everything is fine until the following from the debuglog

:joy: 220-Duett AS - File Spooler Central - duett.no
220 Only for authenticated users - please login
USER myuser
331 Password required
PASS mypassword
230-Welcome! At your service.
230 User logged in.
PBSZ 0
200 PBSZ command successful.
PROT P
200 PROT command successful.
PWD
257 ā€œ/myuserā€ is current directory.
Entry path is ā€˜/myuserā€™
Request has same path as previous transfer
EPRT |1|134.122.59.42|65000|
ftp_perform ends with SECONDARY: 1
200 EPRT command successful.
Connect data stream actively
TYPE A
200 Type set to A.
APPE testcloud.csv
150 Opening ASCII mode data connection.
Preparing for accepting server on data port
Checking for server connect
Data conn was not available immediately
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Checking for server connect
Ctrl conn has data while waiting for data conn
550
Remembering we are in dir ā€œā€
Uploaded unaligned file size (0 out of 645 bytes)
Connection #0 to host ftp-folder.daldata.no left intact

Sorry Iā€™m stumped!
Is the FTPS server expecting the incoming port to be open on 65000?

Could you switch to SFTP and avoid this trouble?

Christian,
If I could I would. I am not in control, itā€™s my clientā€™s accounting package company. I asked them to change their FTP to SFTP or FTPS. They finally changed to FTPS.

So it is waiting on incoming connection on port 65000.

You did use XojoCloud.FirewallPort with direction XojoCloud.FirewallPort.Direction.Incoming for port 65000?

In that test I had it as outgoingā€¦
I just tried it with incoming and I am pleased to say that, but very cautiously, it seems to have worked.
I need to give it a real good testing now.
Thanks for all the patience and help.

1 Like