MBS CURL error

REAL Studio 2011r1
MBS 17.3

Using CURL to upload files via SFTP.

The code below works with one SFTP server I work with and it used to work with another SFTP server I work with.

Since March it no longer works on the latter. I contacted the FTP owner regarding any changes they might have made. They said that they updated their ciphers and they no longer support ciphers that they believe are not secure. I also got the impression that other things might have been upgraded (OS, hardware, etc.), but they did not provide details.

According to them, these are the ciphers they currently support:
3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com

I tried adding those to a list as below:
d.OptionSSLCipherList = “3des-cbc:aes128-cbc:aes192-cbc:aes256-cbc:aes128-ctr:aes192-ctr:aes256-ctr:aes128-gcm@openssh.com:aes256-gcm@openssh.com:chacha20-poly1305@openssh.com”

This seemed to make no difference.

When I run the code below with this SFTP server, I receive the result:
easy handle already used in multi handle
TCP_NODELAY set
Connected to (ftp server, port 22) (#0)
Failure establishing ssh session
Closing connection 0

If you can provide any clues as to what’s causing this, I would appreciate it.

Thanks.

Code:
For i as integer = 0 to count

If Manual_Stop = False then

Dim e as Integer
Dim d as new UploadCURL
Dim b as BinaryStream
Dim currentFolderitem as FolderItem

currentFolderitem = Current_Upload_Array(i)

b = BinaryStream.Open(currentFolderitem)

Dim fileName as String = Current_Upload_Array(i).Name
Dim FTPPathAndFile as String = FTP_Host + FTP_Folder + Current_Pub_FTP_Folder_Name + “/” + fileName

d.stream = b
d.OptionURL = FTPPathAndFile
d.OptionUpload = True
d.OptionVerbose = True
d.CollectDebugData = True
d.OptionInFileSize = b.Length
d.OptionSSHAuthTypes = 2 + 8 // password, not public key
d.OptionUsername = FTP_User
d.OptionPassword = FTP_PW
d.ID = FTPPathAndFile

If CurlMulti.AddCURL(d) then
Log_Session = Log_Session + Get_Current_Time + Chr(09) + "Calling CURL routine for " + fileName + “.” + Chr(09) + “Information” + EndOfLine
AlternatingList1.AddRow “”
AlternatingList1.RowPicture(AlternatingList1.LastIndex) = Blank
AlternatingList1.CellTag(AlternatingList1.LastIndex, 0) = 0
AlternatingList1.customCell(AlternatingList1.lastIndex,3) = new ProgressCell(0,100)
d.Row = AlternatingList1.LastIndex
e=d.Perform
Else
Log_Session = Log_Session + Get_Current_Time + Chr(09) + "Calling CURL routine for " + fileName + “.” + Chr(09) + “Error” + EndOfLine
End If

dim DebugMessages as string = d.DebugData
MsgBox "Result: "+ str(DebugMessages)

End If

Next

any details? Like have you tried SFTP with a different app like FileZilla?

Usually you don’t need to change cipher list.

Except maybe use OptionSSLCipherList with “DEFAULT@SECLEVEL=0” to reduce security by allowing older ciphers.

Yes. It connects with no problems when using FileZilla.

This makes no difference:
Using d.OptionSSLCipherList = “DEFAULT@SECLEVEL=0”

The host name is in the format: ftp.HOSTNAME.com
The password contains “_” and “$” characters.

I wouldn’t think either of those would cause problems.

How about updating the Plugin?

Yo can try the current version.

Yours is 8 years old!

1 Like

He says he’s using RealStudio 2011r1!

Not sure if this will help you:

1 Like

You can try the newest Xojo with the newest MBS to see, if it makes a difference, no?

Currently trying. I had thought about that, but I believe when I purchased MBS plugins last time, I had to request that they be compiled for RB Studio 2011.

I think they have to be RBX files.

Depending on his code that could be quite an undertaking.

1 Like

That might be an option. Thanks.

I also have a version of 2022. I tried it for a while, but I really disliked the more verbose syntax. I stopped using it, which was money thrown away.

I will try to reinstall and activate it and see if it makes a difference using the newest xojo_plugin version of the CURL plugin.

Well, the OpenSSL library and the SSH libraries had major improvements in the last year.

You’d better use a more current Xojo from the last 10 years and more recent MBS Plugins.

On Windows you may be able to unpack the current plugin, copy the Win32 DLL to the plugins folder for REAL Studio to load it. But there may be things in the plugin, that don’t compile.

Using 2022r3.2 and the newest plugin, I received the same “easy handle already used in multi handle” error.

I’m guessing that this might mean that I am using code that is compatible with single uploads, but not compatible with multiple uploads. See below from Google.

If so, I’m not sure why this code works with the other SFTP server that I work with.

From Google:
The error "easy handle already used in multi handle "occurs when a libcurl easy handle, which is already associated with a curl multi handle (used for performing multiple, concurrent transfers), is used in an operation meant for a standalone easy handle, or when the easy handle is reused improperly without being detached or reset.

I’ve been trying to get this to work for over week, when I have time. During that time, I also tried testing with one of the multi-file examples provided by MSB.

I could not get the code working as-is (it attempts to create and upload several files).

I had to add the BinaryStream and its associated code for it to attempt to upload anything.

Is there something wonky in my BinaryStream code?

I received the same error message with this test.

I guess it keeps going back to the fact that it worked fine until they made changes on their end.

I went back to the example file from MBS (CURLS sftp batch upload.xojo_binary_project) in the 2022r1 version of Xojo with the new CURL version and was able to get it working.

Looking at the code, it does not provide a file name to write to the server, so I added a name at the end of the URL and added the username to the URL and it worked.

Adding the username to the path seems to be required for this server. FileZilla adds it automatically. Luckily I noticed this!

I tried adding the username to the path in RB 2011r1, but it still didn’t work.

Adding the file name allowed a file to be written by the code to the server.
d.OptionURL = “sftp://HOST/USERNAME/FOLDER/test.txt”

As a final test, I opened the 2011r1 version of the project in 2022r3.2 and, after several modifications, I was also able to get it working.

Although I’m not where I want to be with this, at least I now know I have an option to use 2022r3.2 and the new version of MBS’s CURL.

Thanks for the help!

1 Like

I didn’t try coping the Win32 DLL to REAL Studio, but I was able to confirm that it does work with Xojo 2022r3.2 and the new CURL plugin.

Thanks!