ume05rw / SharpCifs.Std

SharpCifs.Std is a port from SharpCifs to .NET Standard. Original SharpCifs: https://github.com/zinkpad/SharpCifs
GNU Lesser General Public License v2.1
86 stars 34 forks source link

Connection problem after setting wifi enabled #14

Open ferencmd opened 6 years ago

ferencmd commented 6 years ago

Hello,

I have the following problem. If I start my application on an android smart phone when wifi is off then it cannot connect to the shared folder and it is OK. But if I turn on the wifi without restarting my app then it also cannot connect, the exception is the same as when wifi is off. I tried to call these ones but didn't help: SmbFile.Initialize(); SmbTransport.ClearCachedConnections(); SmbSession.ClearCachedConnections(); SmbTransport.ClearCachedConnections(true);

What can I do in this case?

(If I start my app when wifi is on then all things work. After turning it off then things don't work and it is OK and after turning it on again then things work again.)

ume05rw commented 6 years ago

Thanks for telling! Please give me some time. Perhaps Two weeks later, I can test it.

ume05rw commented 6 years ago

Sorry I made you wait.

Although it was not completely solved, a hint was found. If there are multiple I / Fs in the OS (= multiple IP addresses are assigned), you may not be able to select the I / F for accessing the target share correctly.

Please try it:

SharpCifs.Config.SetProperty("jcifs.smb.client.laddr", "[device's IP Address ]");
SmbFile.Initialize();
...connect and mroe.
ume05rw commented 6 years ago

I released a new version, 2.12. if client.laddr is not specified, It uses IPAddress.Any.