cjimti / iotwifi

Raspberry Pi (arm) wifi configuration container. Configure and control wifi connectivity with a JSON based REST api.
https://imti.co/iot-wifi/
MIT License
303 stars 124 forks source link

Cannot connect as client to wifi network of router #7

Closed suiluj closed 6 years ago

suiluj commented 6 years ago

I cannot connect to my existing wifi at home (or smartphone hotspot) even if the api scan shows the network. I am able to connect to the raspberrypi accesspoint point though.

The command: curl -w "\n" -d '{"ssid":"<nameofmywifi>", "psk":"<passwordofmywifi>"}' -H "Content-Type: application/json" -X POST localhost:8080/connect returns: {"status":"OK","message":"Connection","payload":{"ssid":"","state":"FAIL","ip":"","message":"Unable to connection to <nameofmywifi>"}}

Connect to my wifi as client

cjimti commented 6 years ago

Have you tried another network? Other than a bad password or weak wifi signal there is not a lot to the connection part of the process since that is handed off to wap_supplicant.

suiluj commented 6 years ago

i tried two networks which i already was able to connect to before (the new raspbian stretch way by copying the connection config file on the sd.

country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
        ssid="<my_ssid>"
        psk="<my_passwd>"
}

For testing i used a complete clean raspbian stretch (tried both full version and lite) Connected via ssh over lan cable and followed your "Getting Started" instructions step by step.

Only thing i noticed was an small error when installing docker via:

curl -sSL https://get.docker.com | sh
# Executing docker install script, commit: 8e87f31
+ sudo -E sh -c apt-get update -qq >/dev/null
+ sudo -E sh -c apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sudo -E sh -c curl -fsSL "https://download.docker.com/linux/raspbian/gpg" | apt-key add -qq - >/dev/null
Warning: apt-key output should not be parsed (stdout is not a terminal)
+ sudo -E sh -c echo "deb [arch=armhf] https://download.docker.com/linux/raspbian stretch edge" > /etc/apt/sources.list.d/docker.list
+ [ raspbian = debian ]
+ sudo -E sh -c apt-get update -qq >/dev/null
+ sudo -E sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null
E: Sub-process /usr/bin/dpkg returned an error code (1)
pi@raspberrypi:~ $ 

But docker run --rm hello-world was successful and the only missing part is connecting as client.

Do I have to unmask/re-enable wpa_supplicant.service or do I have to copy the wifi config in /etc/wpa_supplicant/wpa_supplicant.conftoo? (I did not change the standard wpa_supplicant.conf file.)

I did not configure any wifi at all and stayed connected over Lan cable all the time.

opgbaudouin commented 6 years ago

Same issue here - Tried 3 different WiFi all with simple WPA2 and PSK and although i can connect to the device's AP and list the wifi, any attempt fails with same message. No issue doing this manually on same type of RPI (also Raspian Stretch 2018-03-13m with RPI 3 Model B (no plus)...

I get messages like EAPOL - EAP Session-Id is not available

cjimti commented 6 years ago

@opgbaudouin thanks for the report. It seems there is a circumstance where the interface gets into a bad state. I have not been able to reproduce this on my devices.

I need to write up some debugging steps this weekend to help me find the issue.

Elpiojo83 commented 6 years ago

Same here. Attaching logfile just in case that it helps. iotwifi.log

cjimti commented 6 years ago

@Elpiojo83 are you sure wpa_supplicant is not running on the host device?

Elpiojo83 commented 6 years ago

@cjimti i rearealized that i have to execute these commands after every startup, even if wpa_supplicant status says that it´s masked and inactive

$ sudo systemctl mask wpa_supplicant.service  
$ sudo pkill wpa_supplicant
cjimti commented 6 years ago

@Elpiojo83 strange, you must have some other package starting it up. you could disable it in your startup scripts or just remove it completely.

fredrikgisslen commented 6 years ago

Hi, I have the sam problem. Can't find the reason to it. {"status":"OK","message":"Connection","payload":{"ssid":"","state":"FAIL","ip":"","message":"Unable to connection to "}}

EDIT: I realised the problem was that i have to run:

$ sudo systemctl mask wpa_supplicant.service

$ sudo pkill wpa_supplicant

every time I restart