nopnop2002 / esp-idf-smb-client

SMB client example for esp-idf
MIT License
20 stars 8 forks source link

smb2_connect_share failed. Invalid address:smbhost.local Can not resolv into IPv4/v6. #3

Closed fg1998 closed 1 year ago

fg1998 commented 1 year ago

This is what I got every time running, smb-ls or smb-cat. I believe will ocours on entire project. Wifi connection is fine, IP is currentily OK and cannot accesse share via MAcos Server unit mount

I (1470) wifi:AP's beacon interval = 102400 us, DTIM period = 1 I (1500) wifi:idx:0 (ifx:0, e8:48:b8:34:88:d6), tid:0, ssn:0, winSize:64 I (2480) esp_netif_handlers: sta ip: 192.168.68.80, mask: 255.255.255.0, gw: 192.168.68.1 I (2480) main: got ip:192.168.68.80 I (2480) main: connected to ap SSID:outrun I (2490) main: CONFIG_SMB_USER=[smbuser] I (2490) main: CONFIG_SMB_HOST=[smbhost.local] I (2500) main: CONFIG_SMB_PATH=[path] I (2500) main: smburl=smb://smbuser@smbhost.local/path/esp-idf-cat.txt E (9510) main: smb2_connect_share failed. Invalid address:smbhost.local Can not resolv into IPv4/v6.

nopnop2002 commented 1 year ago

Try ping and smbclient from a machine other than smbhost.

$ ping smbhost.local

$ smbclient -L smbhost.local -U smbuser
Enter WORKGROUP\smbuser's password:

        Sharename       Type      Comment
        ---------       ----      -------
        print$          Disk      Printer Drivers
        share           Disk
        IPC$            IPC       IPC Service (voyager server (Samba, Ubuntu))
SMB1 disabled -- no workgroup available

this is mine:

$ LANG=C ping voyager.local
PING voyager.local (192.168.10.39) 56(84) bytes of data.
64 bytes from 192.168.10.39 (192.168.10.39): icmp_seq=1 ttl=64 time=0.346 ms
64 bytes from 192.168.10.39 (192.168.10.39): icmp_seq=2 ttl=64 time=0.241 ms

$ smbclient -L voyager.local -U nop
Enter WORKGROUP\nop's password:

        Sharename       Type      Comment
        ---------       ----      -------
        print$          Disk      Printer Drivers
        share           Disk
        IPC$            IPC       IPC Service (voyager server (Samba, Ubuntu))
SMB1 disabled -- no workgroup available
fg1998 commented 1 year ago

IP is pinging fine, but no mDNS name resolution. I change the network from TPLINK DECO mesh router to TPLink WR840n, because some forums report mDNS issues with Deco, but no success yet, but some progress. Also change from MacOS to a Linux box, here is mine

Same error, new IP

I (991) wifi:<ba-add>idx:0 (ifx:0, 90:9a:4a:ac:ce:aa), tid:0, ssn:5, winSize:64
I (1041) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (2481) esp_netif_handlers: sta ip: 192.169.0.101, mask: 255.255.255.0, gw: 192.169.0.1
I (2481) main: got ip:**_192.169.0.101_**
I (2481) main: connected to ap SSID:lab
I (2491) main: CONFIG_SMB_USER=[smbuser]
I (2491) main: CONFIG_SMB_HOST=[smbhost.local]
I (2501) main: CONFIG_SMB_PATH=[path]
I (2501) main: smburl=smb://smbuser@smbhost.local/path/esp-idf-cat.txt
E (9511) main: smb2_connect_share failed. Invalid address:smbhost.local  Can not resolv into IPv4/v6.

Ping IP if fine

fg1998@fg1998-ULTRATOP-BRIX  ~  ping 192.169.0.101
PING 192.169.0.101 (192.169.0.101) 56(84) bytes of data.
64 bytes from 192.169.0.101: icmp_seq=1 ttl=255 time=221 ms
64 bytes from 192.169.0.101: icmp_seq=2 ttl=255 time=38.9 ms

smbclient no name resolution

fg1998@fg1998-ULTRATOP-BRIX  ~  smbclient -L smbhost.local -U smbuser                
do_connect: Connection to smbhost.local failed (Error NT_STATUS_UNSUCCESSFUL)

but with IP i got new error

fg1998@fg1998-ULTRATOP-BRIX  ~  smbclient -L 192.169.0.101 -U smbuser
do_connect: Connection to 192.169.0.101 failed (Error NT_STATUS_CONNECTION_REFUSED)

some parts of kconfig.projbuild

 config SMB_NEED_PASSWORD
        bool "Shared access requires password"
        help
            Shared access requires password

    config SMB_PASSWORD
        depends on SMB_NEED_PASSWORD
        string "SMB password"
        default "smbpass"
        help
            Password of Username.

I also have another wifi router no TPLink brand, I will try on this one. Maybe TPlink issues with Mdns, I dont know, because I had another Apple devices on network and bonjour (with use mDNS) is working fine

Regards

fg1998 commented 1 year ago

Moving from TPlink network stuff to Mercusys AC12G router with a brand new network, and same issues I dont believe is something network related after those tests cenarios

nopnop2002 commented 1 year ago

These should be changed according to your environment. You are using the default values, but you will need to adapt them to your environment.

Configuration

You have to set this config value with menuconfig.


fg1998@fg1998-ULTRATOP-BRIX  ~  smbclient -L 192.169.0.101 -U smbuser
do_connect: Connection to 192.169.0.101 failed (Error NT_STATUS_CONNECTION_REFUSED)

This issue seems to be a problem with your SMB server configuration, not a library problem First you need to resolve this.

fg1998 commented 1 year ago

I'm using my own environment variables, setting up with idf.py menuconfig.

This is the log when using a valid and correct IP (variables are configured in idf.py menuconfig)

W (1012) wifi: [pm.c,479] AP's beacon interval = 102400 us, DTIM period = 1
W (1482) wifi: [hal_ampdu.c,45] <ba-add>idx:0 (ifx:0, e8:48:b8:34:89:12), tid:0, ssn:0, winSize:64
I (2482) esp_netif_handlers: sta ip: 192.168.68.154, mask: 255.255.255.0, gw: 192.168.68.1
I (2482) main: got ip:192.168.68.154
I (2482) main: connected to ap SSID:outrun
I (2492) main: CONFIG_SMB_USER=[smbuser]
I (2492) main: CONFIG_SMB_HOST=[192.168.68.154]
I (2502) main: CONFIG_SMB_PATH=[path]
I (2502) main: smburl=smb://smbuser@192.168.68.154/path
**_E (2512) main: smb2_connect_share failed. smb2_service failed with : Socket connect failed with 104_**
And those are the lines when using some smbhost name (also configured in idf.py menuconfig)
W (1072) wifi: [pm.c,479] AP's beacon interval = 102400 us, DTIM period = 1
W (1542) wifi: [hal_ampdu.c,45] <ba-add>idx:0 (ifx:0, e8:48:b8:34:88:d6), tid:0, ssn:0, winSize:64
I (2532) esp_netif_handlers: sta ip: 192.168.68.154, mask: 255.255.255.0, gw: 192.168.68.1
I (2532) main: got ip:192.168.68.154
I (2532) main: connected to ap SSID:outrun
I (2542) main: CONFIG_SMB_USER=[smbuser]
I (2542) main: CONFIG_SMB_HOST=[smb.local]
I (2542) main: CONFIG_SMB_PATH=[]
I (2552) main: smburl=smb://smbuser@smb.local/
**_E (9562) main: smb2_connect_share failed. Invalid address:smb.local  Can not resolv into IPv4/v6._**
nopnop2002 commented 1 year ago

These are not correct. 192.168.68.154 is the ESP32 IP address, not the SMB server IP address.

I (2492) main: CONFIG_SMB_USER=[smbuser] I (2492) main: CONFIG_SMB_HOST=[192.168.68.154] I (2502) main: CONFIG_SMB_PATH=[path]

This is software for connecting from ESP32 to Windows, Linux, etc.

The IP address of the SMB file server(=SMB Host) is the Windows or Linux IP.

Is your SMB host Windows or Linux or Macintosh?

What is your SMB host's IP address?

What is your SMB host login name?

What is your SMB host's login password?

What is the shared folder name on your SMB host?

fg1998 commented 1 year ago

Sorry about the misunderstood. I thought it's some kind of smb host (smb server) to share esp32 flash memory files. Sorry about that, it's perfect clear on readme it's a smb client. Please close the issue and thanks for your time

nopnop2002 commented 1 year ago

Sharing the ESP32's Flash memory file(SPIFFS file) using the SMB protocol is an interesting idea. I will try the challenge.