0 votes
by (480 points)

I am getting below exception while connecting to SFTP server via Rebex. SFTP "Authentication process Failed with Exception: No connection could be made because the target machine actively refused it"

I am suing Rebex dll with version 6.0.8372.0 and my application is working in .net framework 4.6.1. with WINSCP connectivity is fine. Also telnet was tried for the IP with port and it is also fine.

Connectivity Code in c#
Sftp objSFTP
objSFTP.Connect(sSFTPHost[0], int.Parse(sSFTPHost[1]));
objSFTP.Login(sSFTPHost[2], sSFTPHost[3]);

1 Answer

0 votes
by (144k points)

Try connecting using .NET API. Does this work, or does it fail with "No connection coud be made ..." as well?

using System.Net;
using System.Net.Sockets;
using System.Linq;

var entry = Dns.GetHostEntry(sSFTPHost[0]);
var address = entry.AddressList.Where(address => address.AddressFamily == AddressFamily.InterNetwork).First();
var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Connect(address, int.Parse(sSFTPHost[1]));