home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.77k stars 28.92k forks source link

Cant connect in QVR Pro integration #33479

Closed fribse closed 3 years ago

fribse commented 4 years ago

The problem

Can't connect, full rights given to the user. It seems that it can't connect with https, it has both http and https access, but will of course default to https. It is not currently set up to force https. The nas has a proper certificate, and the URL suits the certificate, but it seems to try and connect via IP instead? The port it shows in the log is the https port.

Environment

Problem-relevant configuration.yaml

From the configuration

qvr_pro:
  host: private.url.dk
  username: !secret qvruser
  password: !secret qvrpass

Traceback/Error logs

2020-03-31 20:39:44 ERROR (MainThread) [homeassistant.setup] Error during setup of component qvr_pro
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
OSError: [Errno 101] Network unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 387, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 184, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0xffff7b2de890>: Failed to establish a new connection: [Errno 101] Network unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='my.url.dk', port=8080): Max retries exceeded with url: /cgi-bin/authLogin.cgi?user=ha-qvr-pro&pwd=elRFaGp4YWR1bnM2UFc4NHNqdkVwenRG&serviceKey=1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff7b2de890>: Failed to establish a new connection: [Errno 101] Network unreachable'))

Additional information

QNAP QTS 4.4.1.16

springstan commented 4 years ago

Could you please take a look at this issue @oblogic7? Thanks 👍

oblogic7 commented 4 years ago

The attached logs are showing errors for QNAP integration not QVR Pro integration.

oblogic7 commented 4 years ago

Regarding QVR Pro connectivity, I think it will work by specifying port 443 on the config. This will be possible once #33070 is released.

fribse commented 4 years ago

@oblogic7 Sorry about the log, I've corrected the original post. I tried giving the https port (which is not 443), and that just messed this up even more in the current release.

principino1984 commented 4 years ago

same thing here... not showing anything, just a "Green check" on the cameras

image

oblogic7 commented 4 years ago

@principino1984 That image is generated by QVR Pro. I have a single camera that shows that image as well. I'm not sure what causes QVR to show that image, but my theory is that it has to do with the stream format and QVR Pro not being able to relay/transcode it for use via their endpoint. I will dig into it further.

I tried giving the https port (which is not 443), and that just messed this up even more in the current release.

@fribse Can you elaborate on what you mean by messed it up even more? Are the logs from trying configuration on original port or from using secure port?

fribse commented 4 years ago

@oblogic7 Sorry, I think the problem I have posted is very different from @principino1984.

I have both a http on 8080 and https port that is non-standard. I usually have the setting 'secure only' set up, I've disabled that for now. The QNAP has a verifiable certificate on the https.

In the configuration I have given no port. If I gave it a port number at that time (like private.url.dk:1000), the URL was shown like this in the log: http://private.url.dk:1000:8080 I will retest now that it's on .108.2

fribse commented 4 years ago

Ok, it sort of shows the same problem:

2020-04-10 13:34:13 WARNING (MainThread) [homeassistant.setup] Setup of qvr_pro is taking over 10 seconds.
2020-04-10 13:46:06 ERROR (MainThread) [homeassistant.setup] Error during setup of component qvr_pro
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 380, in prepare_url
    scheme, auth, host, port, path, query, fragment = parse_url(url)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/url.py", line 392, in parse_url
    return six.raise_from(LocationParseError(source_url), None)
  File "<string>", line 3, in raise_from
urllib3.exceptions.LocationParseError: Failed to parse: http://private.url:1000:None/cgi-bin/authLogin.cgi

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 175, in _async_setup_component
    component.setup, hass, processed_config  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/qvr_pro/__init__.py", line 58, in setup
    qvrpro = Client(user, password, host, port=port)
  File "/usr/local/lib/python3.7/site-packages/pyqvrpro/client.py", line 20, in __init__
    self.connect()
  File "/usr/local/lib/python3.7/site-packages/pyqvrpro/client.py", line 33, in connect
    response = requests.get(login_url, params=params)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 516, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 459, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 314, in prepare
    self.prepare_url(url, params)
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 382, in prepare_url
    raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: http://private.url:1000:None/cgi-bin/authLogin.cgi
oblogic7 commented 4 years ago

This is a bug with the library. I will try to work up a fix for it this weekend.

fribse commented 4 years ago

@oblogic7 sounds great.

oblogic7 commented 4 years ago

@fribse #33901 should fix the error.

oblogic7 commented 4 years ago

@fribse Also, please make sure that you are specifying the port according to the docs. It should not be specified as part of the host.

fribse commented 4 years ago

Sounds very interesting, how do I test it?

oblogic7 commented 4 years ago

Depends on your setup.  I use straight Docker for my vanilla HA Core deployment, which means I can build with the container tagged as RC to get the change.  I'm not sure how to do it for HASS.io.

fribse commented 4 years ago

I can see that it has been merged into the dev, how do I see for which release, is it for 0.109

fribse commented 4 years ago

@oblogic7,Oh, I can connect now, wasn't aware of the PORT setting, but I have to set it to non-encrypted connection, it fails on https (even with the correct hostname/url). Oh, and the one RTSP camera (Sonoff GK-200MP2-B) that is connected to the QNAP just shows the symbol mentioned by principino1984. The others, Hikvision, works fine.

konzolec commented 4 years ago

Same here 1 Dahua works the other showing only icon

oblogic7 commented 4 years ago

Still working with QVR support on this issue. Hope to have a resolution soon.

grubis commented 3 years ago

I also have one camera that shows the correct view (channel 1 - Foscam) and one camera with just the icon aforementioned (channel 2 - Ezviz Doorbell Camera). If there's anymore information I can provide to help resolve the issue, please let me know.

Tovrin commented 3 years ago

Has there been any resolution to this> I've only just tried setting it up and I had to turn off hte "Force secure connection (HTTPS) only" option in QVR. After getting that, I just get the camera and green tick image.

oblogic7 commented 3 years ago

Unfortunately, QVR support was not helpful with this issue and I haven't found any way around the camera icon being shown instead of the stream.

rijoymanghat commented 3 years ago

Ok, so the camera icon issue still exists. I was banging my head thinking its something to do with my configuration.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.