srichter / asksonic

An Alexa skill to play music from Subsonic API compatible music servers
MIT License
59 stars 17 forks source link

AttributeError: 'NoneType' object has no attribute 'sendall' #9

Closed blastbeng closed 2 years ago

blastbeng commented 2 years ago

Hello, I don't really understand why i'm getting this error but looks like asksonic can't talk with the airsonic rest apis:

11:37:17 PM web.1 |  {"playerActivity": "STOPPED"}
11:37:17 PM web.1 |  [2022-01-25 23:37:17,701] DEBUG in navigation: Shuffle Library
11:37:17 PM web.1 |  192.168.1.160 - - [25/Jan/2022 23:37:17] "POST /alexa HTTP/1.1" 500 -
11:37:17 PM web.1 |  Traceback (most recent call last):
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2069, in __call__
11:37:17 PM web.1 |      return self.wsgi_app(environ, start_response)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2054, in wsgi_app
11:37:17 PM web.1 |      response = self.handle_exception(e)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2051, in wsgi_app
11:37:17 PM web.1 |      response = self.full_dispatch_request()
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1501, in full_dispatch_request
11:37:17 PM web.1 |      rv = self.handle_user_exception(e)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1499, in full_dispatch_request
11:37:17 PM web.1 |      rv = self.dispatch_request()
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1485, in dispatch_request
11:37:17 PM web.1 |      return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/site-packages/flask_ask/core.py", line 890, in _flask_view_func
11:37:17 PM web.1 |      result = self._map_intent_to_view_func(self.request.intent)()
11:37:17 PM web.1 |    File "/app/asksonic/intents/navigation.py", line 25, in play_random_tracks
11:37:17 PM web.1 |      tracks = subsonic.random_tracks(tracks_count)
11:37:17 PM web.1 |    File "/app/asksonic/utils/subsonic/api.py", line 81, in random_tracks
11:37:17 PM web.1 |      tracks = self.getRandomSongs(count)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/site-packages/libsonic/connection.py", line 1353, in getRandomSongs
11:37:17 PM web.1 |      res = self._doInfoReq(req)
11:37:17 PM web.1 |    File "/app/asksonic/utils/subsonic/api.py", line 25, in _doInfoReq
11:37:17 PM web.1 |      return super()._doInfoReq(req)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/site-packages/libsonic/connection.py", line 2781, in _doInfoReq
11:37:17 PM web.1 |      res = self._opener.open(req)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/urllib/request.py", line 517, in open
11:37:17 PM web.1 |      response = self._open(req, data)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/urllib/request.py", line 534, in _open
11:37:17 PM web.1 |      result = self._call_chain(self.handle_open, protocol, protocol +
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/urllib/request.py", line 494, in _call_chain
11:37:17 PM web.1 |      result = func(*args)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/site-packages/libsonic/connection.py", line 56, in https_open
11:37:17 PM web.1 |      return self.do_open(HTTPSConnectionChain, req)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/urllib/request.py", line 1346, in do_open
11:37:17 PM web.1 |      h.request(req.get_method(), req.selector, req.data, headers,
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/http/client.py", line 1285, in request
11:37:17 PM web.1 |      self._send_request(method, url, body, headers, encode_chunked)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/http/client.py", line 1331, in _send_request
11:37:17 PM web.1 |      self.endheaders(body, encode_chunked=encode_chunked)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/http/client.py", line 1280, in endheaders
11:37:17 PM web.1 |      self._send_output(message_body, encode_chunked=encode_chunked)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/http/client.py", line 1040, in _send_output
11:37:17 PM web.1 |      self.send(msg)
11:37:17 PM web.1 |    File "/usr/local/lib/python3.9/http/client.py", line 1001, in send
11:37:17 PM web.1 |      self.sock.sendall(data)
11:37:17 PM web.1 |  AttributeError: 'NoneType' object has no attribute 'sendall'

Here my config:

# Subsonic server information
ASKS_SUBSONIC_URL=https://airsonic.mydomain.it
ASKS_SUBSONIC_USER=user
ASKS_SUBSONIC_PASS=pw
ASKS_SUBSONIC_PORT=4040
#ASKS_SUBSONIC_SERVERPATH=/rest
ASKS_SUBSONIC_APIVERSION=1.16.1
#ASKS_SUBSONIC_APPNAME=py-sonic

# AskSonic server config
ASKS_HOST=0.0.0.0
ASKS_PORT=5000
ASKS_ROUTE_PREFIX=/alexa

# AskSonic config
#ASKS_EXTRA_SECRET=
ASKS_TRACKS_COUNT=200

I have airsonic under nginx reverse proxy on https://airsonic.mydomain.it (port 4040) and asksonic under https://airsonic.mydomain.it/alexa, reversed to port 5000

What am i doing wrong?

For subsonic i'm using this docker-image: https://github.com/linuxserver/docker-airsonic-advanced

The reverse proxy is done like that:

  location / {
        proxy_http_version                 1.1;
        proxy_set_header Connection        "Upgrade";
        proxy_set_header Host              $http_host;
        proxy_set_header Origin            '';
        proxy_set_header Upgrade           $http_upgrade;
        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host  $http_host;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_max_temp_file_size           0;
        proxy_buffering                    off;
        proxy_request_buffering            off;
        client_max_body_size               0;
        proxy_pass http://192.168.1.160:4040;
        proxy_redirect                     http:// https://;

    }

    location /alexa {
         proxy_pass http://192.168.1.160:5000;
    proxy_headers_hash_max_size 512;
            proxy_headers_hash_bucket_size 64;

            add_header Front-End-Https on;
            proxy_set_header Range $http_range;
        proxy_set_header If-Range $http_if_range;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        #Next three lines allow websockets
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        }

Thanks

blastbeng commented 2 years ago

Got it working!

The error was this: ASKS_SUBSONIC_PORT=4040 the correct port is the https one. 443.