rgerganov / py-air-control

Command line app for controlling Philips air purifiers
MIT License
256 stars 52 forks source link

No connection could be made because the target machine actively refused it AC2729 #91

Open Olgidos opened 3 years ago

Olgidos commented 3 years ago

I have set up my AC2729 through the mobile app and now want to check the data. But I get the following error (Windows 10):

--ipaddr 192.168.178.43 Exchanging secret key with the device ... Traceback (most recent call last): File "c:\users\theolg\appdata\local\programs\python\python39\lib\urllib\request.py", line 1346, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "c:\users\theolg\appdata\local\programs\python\python39\lib\http\client.py", line 1253, in request self._send_request(method, url, body, headers, encode_chunked) File "c:\users\theolg\appdata\local\programs\python\python39\lib\http\client.py", line 1299, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "c:\users\theolg\appdata\local\programs\python\python39\lib\http\client.py", line 1248, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "c:\users\theolg\appdata\local\programs\python\python39\lib\http\client.py", line 1008, in _send_output self.send(msg) File "c:\users\theolg\appdata\local\programs\python\python39\lib\http\client.py", line 948, in send self.connect() File "c:\users\theolg\appdata\local\programs\python\python39\lib\http\client.py", line 919, in connect self.sock = self._create_connection( File "c:\users\theolg\appdata\local\programs\python\python39\lib\socket.py", line 843, in create_connection raise err File "c:\users\theolg\appdata\local\programs\python\python39\lib\socket.py", line 831, in create_connection sock.connect(sa) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "c:\users\theolg\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\theolg\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\TheOlg\AppData\Local\Programs\Python\Python39\Scripts\airctrl.exe__main.py", line 7, in File "c:\users\theolg\appdata\local\programs\python\python39\lib\site-packages\pyairctrl\airctrl.py", line 444, in main c = HTTPAirCli(device["ip"]) File "c:\users\theolg\appdata\local\programs\python\python39\lib\site-packages\pyairctrl\airctrl.py", line 100, in init self._client = HTTPAirClient(host, debug) File "c:\users\theolg\appdata\local\programs\python\python39\lib\site-packages\pyairctrl\http_client.py", line 108, in init__ self.load_key() File "c:\users\theolg\appdata\local\programs\python\python39\lib\site-packages\pyairctrl\http_client.py", line 156, in load_key self._get_key() File "c:\users\theolg\appdata\local\programs\python\python39\lib\site-packages\pyairctrl\http_client.py", line 119, in _get_key with urllib.request.urlopen(req) as response: File "c:\users\theolg\appdata\local\programs\python\python39\lib\urllib\request.py", line 214, in urlopen return opener.open(url, data, timeout) File "c:\users\theolg\appdata\local\programs\python\python39\lib\urllib\request.py", line 517, in open response = self._open(req, data) File "c:\users\theolg\appdata\local\programs\python\python39\lib\urllib\request.py", line 534, in _open result = self._call_chain(self.handle_open, protocol, protocol + File "c:\users\theolg\appdata\local\programs\python\python39\lib\urllib\request.py", line 494, in _call_chain result = func(*args) File "c:\users\theolg\appdata\local\programs\python\python39\lib\urllib\request.py", line 1375, in http_open return self.do_open(http.client.HTTPConnection, req) File "c:\users\theolg\appdata\local\programs\python\python39\lib\urllib\request.py", line 1349, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>

Olgidos commented 3 years ago

When i run it without IP address i get: airctrl Traceback (most recent call last): File "c:\users\theolg\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\theolg\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\TheOlg\AppData\Local\Programs\Python\Python39\Scripts\airctrl.exe__main__.py", line 7, in File "c:\users\theolg\appdata\local\programs\python\python39\lib\site-packages\pyairctrl\airctrl.py", line 435, in main devices = HTTPAirCli.ssdp(debug=args.debug) File "c:\users\theolg\appdata\local\programs\python\python39\lib\site-packages\pyairctrl\airctrl.py", line 94, in ssdp response = HTTPAirClient.ssdp(timeout, repeats) File "c:\users\theolg\appdata\local\programs\python\python39\lib\site-packages\pyairctrl\http_client.py", line 71, in ssdp s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) AttributeError: module 'socket' has no attribute 'SO_REUSEPORT'

rgerganov commented 3 years ago

This is the second report for problems with AC2729. The first one was issue #89. Maybe Philips changed the communication protocol again. If anyone can debug and provide more information, that would be very helpful.

Olgidos commented 3 years ago

I would like to help you debug. Could you give me a small introduction on the best approach? Which function would you consider inspecting first?

Eipifi commented 1 year ago

Hi all,

Same problem here, getting a Connection refused error.

$ airctrl --ipaddr 192.168.88.190
Exchanging secret key with the device ...
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 941, in connect
    self.sock = self._create_connection(
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/socket.py", line 845, in create_connection
    raise err
  File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/socket.py", line 833, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

Also getting the same error when trying out https://github.com/firescry/philips-air-purifier, which is based on py-air-control but looks like an independent implementation. So it seems that the protocol indeed changed.