JAndrassy / WiFiEspAT

Arduino networking library. Standard Arduino WiFi networking API over ESP8266 or ESP32 AT commands.
GNU Lesser General Public License v2.1
271 stars 44 forks source link

Cannot connect to MQTT broker #105

Closed nxor closed 1 year ago

nxor commented 1 year ago

Hi,

I try to connect to my mosquitto broken on my local network.

But I cannot connect and get error : -1.

I get this log when trying to connect:

Hello Pico and ESP32C3 AT success esp INFO: soft reset esp> AT+RST ...sent esp> OK ...ignored esp> WIFI DISCONNECT ...ignored esp> ready ...matched esp> ATE0 ...sent esp> ATE0 ...ignored esp> OK ...matched esp> AT+CIPMUX=1 ...sent esp> OK ...matched esp> AT+CIPRECVMODE=1 ...sent esp> OK ...matched esp> AT+CWMODE? ...sent esp> +CWMODE:1 ...matched esp> OK ...matched esp INFO: wifi status esp> AT+CIPSTATUS ...sent esp> WIFI CONNECTED ...ignored esp> STATUS:0 ...matched esp> OK ...matched esp INFO: quit AP current esp> AT+CIPDNS_CUR=0 ...sent esp> ERROR ...error esp ERROR: expected OK got ERROR esp> AT+CWDHCP_CUR=1,1 ...sent esp> ERROR ...error esp ERROR: expected OK got ERROR esp> AT+CWQAP ...sent esp> WIFI DISCONNECT ...ignored esp> OK ...matched esp INFO: end SoftAP persistent esp INFO: STA MAC query esp> AT+CIPSTAMAC? ...sent esp> +CIPSTAMAC:"" ...matched esp> OK ...matched MAC: Scanning available networks... Scan Networks esp INFO: list AP esp> AT+CWLAPOPT=1,31 ...sent esp> OK ...matched esp> AT+CWLAP ...sent esp> ? esp> busy p... ...ignored esp> +CWLAP:(3,"Wifi1",-62,"",1) ...matched esp> +CWLAP:(3,"BELL001",-80,"",11) ...matched esp> +CWLAP:(3,"[range]_E30AJT7113020J",-96,"",1) ...ignored esp> OK ...matched Connecting to the network... Attempting to connect to WPA SSID: Wifi1 esp INFO: join AP Wifi1 persistent esp> AT+CWJAP="Wifi1","notrealpassword" ...sent esp> WIFI CONNECTED ...ignored esp> WIFI GOT IP ...ignored esp> OK ...matched esp> AT+CWAUTOCONN=1 ...sent esp> OK ...matched .esp INFO: STA IP query esp> AT+CIPSTA? ...sent esp> +CIPSTA:ip:"192.168.0.209" ...matched esp> +CIPSTA:gateway:"192.168.0.1" ...matched esp> +CIPSTA:netmask:"255.255.255.0" ...matched esp> OK ...matched IP Address: 192.168.0.209 esp INFO: STA MAC query esp> AT+CIPSTAMAC? ...sent esp> +CIPSTAMAC:"" ...matched esp> OK ...matched MAC address: ** Attempting MQTT connection...192.168.0.111esp INFO: free linkId is 4 esp INFO: start TCP to 192.168.0.111:1883 on link 4 esp> AT+CIPSTART=4,"TCP","192.168.0.111",1883 ...sent esp> 4,CONNECT ...ignored esp> OK ...matched esp INFO: BuffManager returned buff.stream at 0 for linkId 4 esp INFO: sync esp> AT+CIPSTATUS ...sent esp> STATUS:3 ...matched esp> +CIPSTATUS:4,"TCP","192.168.0.111",1883,54585,0 ...matched esp> OK ...end of list esp> AT+CIPRECVLEN? ...sent esp> +CIPRECVLEN:-1,-1,-1,-1,0 ...matched esp> OK ...matched esp INFO: send data on link 4 esp> AT+CIPSEND=4,51 ...sent esp> OK ...ignored esp> > ...matched esp> Recv 51 bytes ...matched esp> SEND OK ...matched esp INFO: sent 51 bytes on link 4 esp INFO: sync esp> AT+CIPSTATUS ...sent esp> +IPD,4,4 ...processed esp> STATUS:3 ...matched esp> +CIPSTATUS:4,"TCP","192.168.0.111",1883,54585,0 ...matched esp> OK ...end of list esp> AT+CIPRECVLEN? ...sent esp> +CIPRECVLEN:-1,-1,-1,-1,4 ...matched esp> OK ...matched esp INFO: get data on link 4 esp> AT+CIPRECVDATA=4,64 ...sent esp> +CIPRECVDATA ...matched esp> , ...ignored esp> OK ...matched esp INFO: got 1 bytes on link 4 esp INFO: get data on link 4 esp> AT+CIPRECVDATA=4,64 ...sent esp> 4,CLOSED ...processed esp INFO: closed linkId 4 esp> ERROR ...error esp ERROR: expected +CIPRECVDATA got ERROR esp ERROR: error receiving on link 4 failed, rc=-1 try again in 5 seconds

I can provide the script is required.

is this normal:

esp> AT+CIPDNS_CUR=0 ...sent esp> ERROR ...error esp ERROR: expected OK got ERROR esp> AT+CWDHCP_CUR=1,1 ...sent esp> ERROR ...error esp ERROR: expected OK got ERROR

I know I can HTTP connect to my server and get the html code. Now I'm trying to connect to MQTT broker on another port.

Anything I can try ?

Thanks for your help !

JAndrassy commented 1 year ago

you didn't switch the library to AT 2. see the README