Hi,
we're working on a remote update feature with which an embedded software is supposed to be able to retrieve version updates from an update server. We've implemented the basic features with the Rebex libraries. Now we consistently run into this error:
SSH: Rebex.Net.SshException: The connection was closed by the server. Make sure you are connecting to an SSH or SFTP server.
Any help is greatly appreciated.
What we've tried / found out
- we're sure the device has internet access (e.g. pinging google works, tracert shows the target gets correctly resolved, telnet returns SSH-2.0...)
- we're sure its an actual SFTP server that does not block the calls (as far as the server is concerned nothing ever tried to communicate)
- whatever we could find on similar topics in this forum
- calling Rebex.Net.ConnectionManagement.ConnectionManager.TryConnect() returns false
- Connections generally worked for a while on different devices, but as soon as the connection failed on one, we cannot restore it anymore. Is there some kind of cache, we could kill?
Logs
(I tried to hide sensible data)
2025-01-23 15:04:49 Opening log file.
2025-01-23 15:04:49 INFO FileLogWriter(1)[116523074] Info: Assembly: Rebex.Common R5.10 for .NET Compact Framework 3.5
2025-01-23 15:04:49 INFO FileLogWriter(1)[116523074] Info: Platform: Windows CE 7.0.2877 32-bit; CLR: 3.5.14223.0
2025-01-23 15:04:49 DEBUG FileLogWriter(1)[116523074] Info: Culture: en; windows-1252
2025-01-23 15:05:26 INFO FileTransferClient(1)[132382830] Info: Connecting to : using Sftp.
2025-01-23 15:05:26 INFO FileTransferClient(1)[132382830] Info: Assembly: Rebex.Sftp R5.10 for .NET Compact Framework 3.5
2025-01-23 15:05:26 INFO FileTransferClient(1)[132382830] Info: Platform: Windows CE 7.0.2877 32-bit; CLR: 3.5.14223.0
2025-01-23 15:05:26 DEBUG FileTransferClient(1)[132382830] Info: Culture: en; windows-1252
2025-01-23 15:05:26 INFO FileTransferClient(1)[132382830] Info: Using proxy none.
2025-01-23 15:05:26 DEBUG FileTransferClient(1)[132382830] Proxy: Connecting to : (no proxy).
2025-01-23 15:05:26 DEBUG FileTransferClient(1)[132382830] Proxy: Connection established.
2025-01-23 15:05:29 ERROR FileTransferClient(1)[132382830] SSH: Rebex.Net.SshException: The connection was closed by the server. Make sure you are connecting to an SSH or SFTP server.
at Rebex.Net.SshSession.aplzc()
at Rebex.Net.SshSession.Negotiate()
at Rebex.Net.Sftp.whjoy.ahcku(ehmzn p0, Boolean p1)
at Rebex.Net.Sftp.hbhug(String p0, Int32 p1, SshParameters p2, ehmzn p3)
at Rebex.Net.Sftp.jpuyt(String p0, Int32 p1, SshParameters p2)
at Rebex.Net.FileTransferClient.Connect(String serverName, Int32 serverPort, FileTransferMode transferMode)
at ... our own code
2025-01-23 15:05:29 ERROR FileTransferClient(1)[132382830] Info: Rebex.Net.SshException: The connection was closed by the server. Make sure you are connecting to an SSH or SFTP server.
at Rebex.Net.SshSession.aplzc()
at Rebex.Net.SshSession.Negotiate()
at Rebex.Net.Sftp.whjoy.ahcku(ehmzn p0, Boolean p1)
at Rebex.Net.Sftp.hbhug(String p0, Int32 p1, SshParameters p2, ehmzn p3)
at Rebex.Net.Sftp.jpuyt(String p0, Int32 p1, SshParameters p2)
at Rebex.Net.FileTransferClient.Connect(String serverName, Int32 serverPort, FileTransferMode transferMode)
at ... our own code
Code
This is basically our code:
_client = new FileTransferClient();
_client.Settings.SslAcceptAllCertificates = true;
// This line is what's causing the error
_client.Connect(settings.FtpHost, settings.FtpPort, FileTransferMode.Sftp);