SharpCifs.Std icon indicating copy to clipboard operation
SharpCifs.Std copied to clipboard

Failed to connect: 0.0.0.0<00>/192.168.1.218

Open donaldhughes opened this issue 7 years ago • 15 comments

I've followed the instructions, but all of the examples produce the same error. I am able to connect to the share from a Mac, other Windows machines, and from another app, AirDisk Pro. The share is on a Windows 10 Professional machine on a Windows Domain. Any ideas or known issues?

Failed to connect: 0.0.0.0<00>/192.168.1.218
2017-11-11 19:11:42.683 NetworkFileSync3[6981:3166492]   at SharpCifs.Smb.SmbTransport.Connect () [0x00025] in <4c9231bb48bc4e91ad96cf2ef3ec2de1>:0 
  at SharpCifs.Smb.SmbTree.TreeConnect (SharpCifs.Smb.ServerMessageBlock andx, SharpCifs.Smb.ServerMessageBlock andxResponse) [0x00162] in <4c9231bb48bc4e91ad96cf2ef3ec2de1>:0 

donaldhughes avatar Nov 12 '17 01:11 donaldhughes

Here's the code chunk I'm running...

SharpCifs.Config.SetProperty("jcifs.smb.client.laddr", "192.168.1.171");  // ip of iPhone
SharpCifs.Config.SetProperty("jcifs.smb.client.lport", "8137");

try
{
        var auth1 = new NtlmPasswordAuthentication("domain", "user", "password");
        var smb1 = new SmbFile("smb://192.168.1.218/Docs/Documentation", auth1);
        Console.WriteLine($"exists? {smb1.Exists()}");
} catch(Exception ex) {
        Console.WriteLine(ex.Message);
}

donaldhughes avatar Nov 12 '17 02:11 donaldhughes

Hi!

The most frequently occurring problems is on a network, but...

on a Windows Domain.

Are you using Active Directory( or NT Domain)? I have not confirmed that it can be used correctly under AD Env, so I will try it.

if you trying on Workdgroup network, remove "domain", like: var auth1 = new NtlmPasswordAuthentication("domain", "user", "password");  ↓ var auth1 = new NtlmPasswordAuthentication(null, "user", "password");

ume05rw avatar Nov 13 '17 05:11 ume05rw

Thanks, it's on a Windows domain. I've tried both a domain account and a local administrator account. I've also tried a share allowing access to Everyone. Fails to connect.

I also tried the "Scan Servers & Shares on LAN" example (specifying the machine instead of scanning the LAN), and it resulted in the same "Failed to connect" exception.

Not sure if it helps, but I am able to connect to this share from my iPad using Stratospherix FileBrowserLite, but NOT from Readdle Documents. I'm assuming there's an underlying difference in how SMB is implemented.

donaldhughes avatar Nov 13 '17 14:11 donaldhughes

Hi! I'm sorry for being late.

I attempted to connect to a share on Active Directory, it succeeded.

Env: [AD-Server] OS: Win2012R2 IP: 192.168.254.21 Domian Name: dobes.local Domain's User: domuser1 Password: P@ssw0rd

[Share-hosted PC] OS: Win10Pro(ver1709-FallCreatorUpdate) IP: 192.168.254.31 Share Name: Share

Code:

public override void ViewDidLoad()
{
    base.ViewDidLoad();
    // Perform any additional setup after loading the view, typically from a nib.

    //Get SmbFile-Object of a folder.
    var auth2 = new NtlmPasswordAuthentication("dobes.local", "domuser1", "P@ssw0rd");
    var folder = new SmbFile("smb://192.168.254.31/Share/", auth2);

    //UnixTime
    var epocDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

    Console.WriteLine("--------------------------------------------------");
    Console.WriteLine("");

    //List items
    foreach (SmbFile item in folder.ListFiles())
    {
        var lastModDate = epocDate.AddMilliseconds(item.LastModified())
                                    .ToLocalTime();
        var name = item.GetName();
        var type = item.IsDirectory() ? "dir" : "file";
        var date = lastModDate.ToString("yyyy-MM-dd HH:mm:ss");
        var msg = $"{name} ({type}) - LastMod: {date}";
        Console.WriteLine(msg);
    }

    Console.WriteLine("");
    Console.WriteLine("--------------------------------------------------");
}

Console:

Loaded assembly: /Users/vm/Library/Developer/CoreSimulator/Devices/0F65016A-0BCE-4914-BDD6-0E1C62011AE1/data/Containers/Bundle/Application/FF36AB38-B43E-437D-A16E-FD32F8B76DE0/SmbTest.app/System.Security.Cryptography.Algorithms.dll [External]
Loaded assembly: /Users/vm/Library/Developer/CoreSimulator/Devices/0F65016A-0BCE-4914-BDD6-0E1C62011AE1/data/Containers/Bundle/Application/FF36AB38-B43E-437D-A16E-FD32F8B76DE0/SmbTest.app/System.Reflection.Extensions.dll [External]
Loaded assembly: /Users/vm/Library/Caches/Xamarin/XMA/Agents/Inspector/iOS/Xamarin.Interactive.iOS.dll [External]
Loaded assembly: /Users/vm/Library/Caches/Xamarin/XMA/Agents/Inspector/iOS/Xamarin.Interactive.dll [External]
2017-11-26 09:43:46.891 SmbTest[1614:29491] --------------------------------------------------
2017-11-26 09:43:46.892 SmbTest[1614:29491] 
Thread started: <Thread Pool> #4
Thread started: <Thread Pool> #5
Thread started: <Thread Pool> #6
Thread started: <Thread Pool> #7
Thread started:  #8
Thread started: <Thread Pool> #9
Thread started: <Thread Pool> #10
Thread started: <Thread Pool> #11
2017-11-26 09:43:48.046 SmbTest[1614:29491] 20171115_ml17.sql (file) - LastMod: 2017-11-15 16:45:32  <- It's file name in the shared folder.
2017-11-26 09:43:48.048 SmbTest[1614:29491] 
2017-11-26 09:43:48.049 SmbTest[1614:29491] --------------------------------------------------
Thread finished: <Thread Pool> #7
Thread finished: <Thread Pool> #6
Thread finished: <Thread Pool> #10

Apparently, this problem seems to be irrelevant to Active Directory.

ume05rw avatar Nov 26 '17 01:11 ume05rw

    var auth1 = new NtlmPasswordAuthentication("domain", "user", "password");
    var smb1 = new SmbFile("smb://192.168.1.218/Docs/Documentation", auth1);
    Console.WriteLine($"exists? {smb1.Exists()}");

Is "Documentation" a folder? If so, '/' is required at the end of the uri string. like:

    var smb1 = new SmbFile("smb://192.168.1.218/Docs/Documentation/", auth1);

ume05rw avatar Nov 26 '17 01:11 ume05rw

Depending on the situation you use, settings such as previous IP address may be left. try Config.Apply() method. like:

SharpCifs.Config.SetProperty("jcifs.smb.client.laddr", "192.168.1.171");  // ip of iPhone
SharpCifs.Config.SetProperty("jcifs.smb.client.lport", "8137");
SharpCifs.Config.Apply(); // <- here

For now, I can not find to come up with these other things...

ume05rw avatar Nov 26 '17 01:11 ume05rw

(I still hope that you are watching here...) I released a new version, 2.12. It's connect even without specifying a local address.

ume05rw avatar Feb 04 '18 12:02 ume05rw

Thanks for checking... I updated the package, but still unable to connect, though. I can still connect to the specific Windows share from a Mac and from Stratospherix FileBrowser for Business app on an iPad. I've tried two different Windows machines, one was running Windows 10 and another running Windows 7.

On Sun, Feb 4, 2018 at 6:33 AM, ume05rw [email protected] wrote:

I still hope that you are watching here...

I released a new version, 2.12. It's connect even without specifying a local address.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ume05rw/SharpCifs.Std/issues/12#issuecomment-362903433, or mute the thread https://github.com/notifications/unsubscribe-auth/AE9B6oBbI09xExeRsYsVpMXLYR4kZfN0ks5tRaOUgaJpZM4Qas-k .

donaldhughes avatar Feb 04 '18 14:02 donaldhughes

Maybe SMB 1.0 on your Windows has been disabled?

SharpCifs.Std only supports up to SMB 1.0. (There is the same restriction as JCIFS)

Last year Wanna Cry virus became popular. As a measure, many PCs seem to have invalidated SMB 1.0.

ume05rw avatar Feb 10 '18 14:02 ume05rw

I am using the jcifs maven jar of version 1.3.17 and facing the same issue

My code is mentioned below: String path="smb://43.90.254.51/NWInput/BDIAutomationNW/Master_Automation_Custom_Network_to_FTP_Input/"; NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",user, pass); SmbFile smbFile = new SmbFile(path,auth); arrFileList = smbFile.listFiles();

Give an error jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/43.90.254.51 jcifs.util.transport.TransportException java.net.SocketException: Connection reset at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at jcifs.util.transport.Transport.readn(Transport.java:29) at jcifs.smb.SmbTransport.peekKey(SmbTransport.java:388) at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:288) at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:319) at jcifs.util.transport.Transport.run(Transport.java:241) at java.lang.Thread.run(Unknown Source)

at jcifs.util.transport.Transport.run(Transport.java:258)
at java.lang.Thread.run(Unknown Source)

please advice

durgesh-vaishy-ngi avatar Jul 03 '19 14:07 durgesh-vaishy-ngi

meet the same problem, as I investigating, my random local port(25293..) is not open(), then I switched to set a specific opened port(1400), SharpCifs.Config.SetProperty("jcifs.smb.client.lport", "1400"); SharpCifs.Config.Apply(); but the code does not work, I still get error with the random port.

evenlee avatar Sep 29 '19 01:09 evenlee

FYI, installed today and met the same problem. Is it still not fixed? But the advertising works, specially the hyper noisy sound :)

jssilva25 avatar Mar 27 '20 13:03 jssilva25

I am facing the same error. can anyone tell how did they fix it?

shrivanKW avatar May 03 '21 20:05 shrivanKW

I think, the issue is something about windows server or server config. When I use it on my dev server, its edition is windows server 2008, it worked. But when I change it to windows server 2022, it appears. I also try to open some windows service and close the firewalls, but still failed.

VigossX avatar Jul 04 '23 05:07 VigossX

I think, the issue is something about windows server or server config. When I use it on my dev server, its edition is windows server 2008, it worked. But when I change it to windows server 2022, it appears. I also try to open some windows service and close the firewalls, but still failed.

maybe the solution is here. https://github.com/ume05rw/SharpCifs.Std/issues/38

VigossX avatar Jul 04 '23 06:07 VigossX