Closed DavidErben closed 1 year ago
Hi, Just to make sure I understand,
Yes exactly, right now I have fixed it by resolving the IP address manually and then use the constructor with the IPAddress directly. I tried to connect from a Win 10 PC to a SMB server running on Windows as well (I think Win 7), so they should be able to handle IPv6, but it might be a problem with one of the machines and/or the network.
I was just curious that by default it will always pick the IPv6 address and if this intended.
theoretically you can have IPv6-only network. I believe that when the library is used under .NET Core 3.0+ on a machine supporting IPv6 there is no issue. There might be an issue here with earlier .NET Core / .NET Framework versions not fully supporting IPv6.
I'll consider whether the library should force IPv4 under such conditions.
I am using .NET 6, but it might be a network issue. So ok for me and I will resolve the IP manually for now. Thanks!
I have same issue with Net core 6 when machine is using IPv6 and you try to connect with server name, //var host = System.Environment.MachineName; var host= "MyCompName01" bool isConnected = client.Connect(host, SMBTransportType.DirectTCPTransport);
this will throw error: System.NotSupportedException: This protocol version is not supported. at System.Net.Sockets.Socket.Connect(IPAddress address, Int32 port) at SMBLibrary.Client.SMB2Client.ConnectSocket(IPAddress serverAddress, Int32 port) at SMBLibrary.Client.SMB2Client.Connect(IPAddress serverAddress, SMBTransportType transport) at SMBLibrary.Client.SMB2Client.Connect(String serverName, SMBTransportType transport)
and if set machine to prefer ipv4 then connection by server name is successful, any solution for this how to handle this because not always is possible to configure usage of version of ip address?
The solution suggested was to manually resolve the hostname to IPv4 and use the overload allowing to specify IPAddress.
I guess we can update the code to prefer IPv4 if both IPv4 and IPv6 are available
The code was updated to prefer IPv4 if both IPv4 and IPv6 are available, the change will be part of the upcoming v1.5.0.
On a system where a hostname has a IPv6 and IPv4 address, the SMBClient.Connect method fails because the first element in the list is an IPv6 address which cannot be handled.
System.NotSupportedException: This protocol version is not supported. at System.Net.Sockets.Socket.Connect(IPAddress address, Int32 port) at SMBLibrary.Client.SMB2Client.ConnectSocket(IPAddress serverAddress, Int32 port) at SMBLibrary.Client.SMB2Client.Connect(IPAddress serverAddress, SMBTransportType transport) at SMBLibrary.Client.SMB2Client.Connect(String serverName, SMBTransportType transport)
Current implementation:
Can be fixed by specifying address family to get only IPv4 addresses: