mvysny / photocloud-frame-slideshow

Android Digital Photo Frame
https://www.android-photo-frame.eu
14 stars 1 forks source link

jcifs.smb.Smbexception: failed to connect to server #141

Closed nascentt closed 3 years ago

nascentt commented 3 years ago

Been using PhotoCloud Slideshow for three years with everything untouched, suddenly the app started showing the error:

The stream failed, retrying. Please wait.

the full error is "warning: error while polling for photos, showing cached photos until the stream and unmetered network comes back online. jcifs.smbexception: failed to connect to server

I tried browsing the slideshow from the app, but just get spinner and the above error. Using any other installed app (such as solid explorer or file manager+) with smb support sees the shares and file though.

It's now been like this for a couple of weeks.

nascentt commented 3 years ago

Was asked to try VLC.

VLC works without issue on the share.

mvysny commented 3 years ago

Thank you for the information. What kind of device are you serving SMB from? Is it using version 3 of the SMB protocol? If yes, can you try to enable SMB v2 support?

nascentt commented 3 years ago

SMB served by Windows 10 . SMB1 and SMB2 is enabled. (I should probably be disabling SMB1 after this is fixed)

mvysny commented 3 years ago

Thank you. Perhaps could you try to disable SMB1 temporarily, to see whether the situation improves?

VLC works without issue on the share.

Damn, I hoped VLC to use one of the libraries highlighted at #100 but unfortunately VLC uses libvlc to access SMB which is a C native library.

What we need to find out is which one of jcifs, cifs-ng or smbj library works for you. Then we know which way to proceed. The simplest way for that would be to find Android demo apps for jcifs, cifs-ng or smbj respectively, which you could download to your phone and try out with your environment.

Alternatively I could simply try to implement a quick-and-dirty client over smbj (or https://github.com/swaechter/smbjwrapper) which you could then test yourself.

mvysny commented 3 years ago

Also, I need to know exactly what kind of errors are you getting. Can you try to add another stream with exactly the same samba server? If the server auto-discovery fails, you can type in IP/share in the worst case, e.g. 192.168.0.22/public.

For example, in my case I'm getting

E/PhotoFrame:AddSambaSha*: Failed to connect to the Samba server smb://192.168.0.22/public/
    jcifs.smb.SmbException: Failed to connect: 0.0.0.0<00>/192.168.0.22
    jcifs.util.transport.TransportException: Connection in error
    jcifs.util.transport.TransportException
    jcifs.smb.SmbException: This client does not support the negotiated dialect.
        at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:329)
        at jcifs.util.transport.Transport.run(Transport.java:241)
        at java.lang.Thread.run(Thread.java:923)
        at jcifs.util.transport.Transport.run(Transport.java:258)
        at java.lang.Thread.run(Thread.java:923)
        at jcifs.util.transport.Transport.connect(Transport.java:154)
        at jcifs.smb.SmbTransport.connect(SmbTransport.java:307)
        at jcifs.smb.SmbTree.treeConnect(SmbTree.java:156)
        at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
        at jcifs.smb.SmbFile.connect(SmbFile.java:954)
        at jcifs.smb.SmbFile.connect0(SmbFile.java:880)
        at jcifs.smb.SmbFile.getType(SmbFile.java:1282)
        at jcifs.smb.SmbFile.doEnum(SmbFile.java:1733)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1715)
        at jcifs.smb.SmbFile.listFiles(SmbFile.java:1648)
        at sk.baka.photoframe.fsimpl.samba.SambaFileSystem$list$1.invoke(SambaFileSystem.kt:48)
        at sk.baka.photoframe.fsimpl.samba.SambaFileSystem$list$1.invoke(SambaFileSystem.kt:21)

I temporarily tried to upgrade to jcifs-codelibs; even though the server discovery failed, connecting to 192.168.0.22/public worked for me, so they definitely improved something. However, in order to not to break old setups, it's probably best to introduce a new SMB impl based on smbj. Let me experiment on that a bit.

mvysny commented 3 years ago

Okay smbj seems to be working for me, I'll add support for this, as a new SMB connector.

mvysny commented 3 years ago

SMBJ connector added in PhotoCloud 1.13.18, should hopefully fix this issue. Please reopen if SMBJ doesn't work for you.

Please let me know if you're in for trying out the newest APK of PhotoCloud, to verify whether the new Samba client works for you.

nascentt commented 3 years ago

Just re-read the last comment, yes I'm in for trying the newest APK. (I originally was waiting for a google play update that never came)

stncrn commented 3 years ago

Ready to try too, on mobile phone + Android TV.

(sorry, I read last comment too quickly, and was waiting for the update in the store)

mvysny commented 3 years ago

Sure thing. Please find the newest APK here: https://drive.google.com/file/d/13KJz9uW7Q8EaRI_vgtCQ59DP5KNkmp0i/view?usp=sharing ; for compatibility reasons I've kept the old Samba stream type around, but please test with the new Samba 3.

stncrn commented 3 years ago

Everything seems to work fine with latest apk & "new" Samba implementation, on both mobile and AndroidTV. Now that this app matches my needs, I just bought to remove ads & Daydream. Thanks again for this fix.

mvysny commented 3 years ago

Thank you kindly for your support, and I'm happy that the new Samba client works for you. Samba is tricky - it's a closed protocol and the library support is tricky.

I'll eventually implement a bunch of other features and release a new version, in a month or so.

nascentt commented 3 years ago

First of all, many thanks for the update. After a couple of hours I finally got it to connect to the share and show images again. So my slideshow is working and I doubt I'll ever touch it again.

However, I ran into numerous issues along the way so figured I'd relay.

I can't summon the keyboard for the text fields by tapping them. I need to rotate the tablet for the keyboard to show. This is reproducible and happens every time I add a new share.

Also, if I rotate my tablet doing the new samba share dialog it clears the already entered text in the form.

I had an issue where I couldn't seem to enter a username or password for my share, there was no way to change focus from the host name field. This occurred multiple times for me however not every time.

When entering new share info, if I used enter it made a new line on the host name field. If I tap the username or password fields they change green but typing still output to the hostname field. This seems to be fixable after a couple of rotates.

I can't use a server host name. I have to use an ip. When using host name I got "Error: failed to connect to server name/sharename Java.net.unknownhostexception: servername" Using ip instead works.

Finally, I was gettimg error: com.hierynomus.mssmb2.smbapiexception STATUS_INVALID_PARAMETER (0xc00000b)

Trying to create the need samba share connection, which was failing on a symbolic link within the share. The previous client didn't have any issues with the symbolic link. The only way to be able to get around the error was by deleting my symbolic link. (The symbolic link had existed for years so isn't a new thing. The previous client worked with the symbolic link and didn't present that error.)

And lastly the obvious: because the new client doesn't replace the old it meant that the existing config didn't work. I have about 50 contents/locations in the old share connection. I had to re-add them to the new connection which is annoying but I'll live.

As stated I now have a working daydream and slideshow again. So I'm content. Just relaying my issues/experiences

Many thanks again.

mvysny commented 3 years ago

Hello, thank you for letting me know that the new Samba client works - I'm really happy that we've got this particular monkey off our backs.

Now to the items:

I can't summon the keyboard for the text fields by tapping them. I need to rotate the tablet for the keyboard to show. This is reproducible and happens every time I add a new share.

Unfortunately it's up to Android to show the keyboard - I haven't done any work from my part to prevent the keyboard from being shown.

Also, if I rotate my tablet doing the new samba share dialog it clears the already entered text in the form.

Right, sorry, that's easily remedied by adding IDs to those edit fields. I'll add that.

I had an issue where I couldn't seem to enter a username or password for my share, there was no way to change focus from the host name field. This occurred multiple times for me however not every time. When entering new share info, if I used enter it made a new line on the host name field. If I tap the username or password fields they change green but typing still output to the hostname field. This seems to be fixable after a couple of rotates.

Those Edit boxes are just Android standard components, with no additional functionality. Could it be your tablet acting up? This looks like a serious Android bug.

I can't use a server host name. I have to use an ip. When using host name I got "Error: failed to connect to server name/sharename Java.net.unknownhostexception: servername" Using ip instead works.

Yes, apparently the new client doesn't use Samba proprietary host name resolution (and Android doesn't seem to use mdns), but it only uses the standard DNS resolution mechanism: https://github.com/hierynomus/smbj/issues/586

Finally, I was gettimg error: com.hierynomus.mssmb2.smbapiexception STATUS_INVALID_PARAMETER (0xc00000b)

Sounds like a bug/defficiency in SMBJ.

And lastly the obvious: because the new client doesn't replace the old it meant that the existing config didn't work.

Yes, that's an unfortunate side-effect of having to support two Samba-related libraries :(

In case there are any further issues, please open new separate bug reports.

mvysny commented 3 years ago

I've locked this issue to prevent off-topic discussion since the new Samba client has been verified to be working. In case of any defficiencies, please open a new bug report.

mvysny commented 3 years ago

Actually, the keyboard issue may originate from the fact that I'm using Anko which constructs the views in a "vanilla" state. I'll just rework the activity to the old&crappy android xml layout stuff.