Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSE: fix sign_path call for compatiblity with 2022.7 #320

Merged
merged 3 commits into from Jul 12, 2022

Conversation

skrobul
Copy link
Contributor

@skrobul skrobul commented Jul 6, 2022

Since home-assistant/core#73829 was merged, HA now requires that full path including the query parameters is signed.

Prior to this commit, the parameters were not included and this resulted in the websocket setup failures due to JWT token being invalid.

This commit resolves #318 for me, although I have not tested this on any older HA instances as I don't have access to any.

Since home-assistant/core#73829 was merged, HA now
requires that full path including the query parameters is signed.

Prior to this commit, the parameters were not included and this resulted in the
websocket setup failures due to JWT token being invalid.

This commit resolves AlexxIT#318 for me,
although I have not tested this on any older HA instances as I don't have access
to any.
@GenkaOk
Copy link
Contributor

GenkaOk commented Jul 6, 2022

Thank you, working!

@Claudio1L
Copy link

#320 does not fix for me

@skrobul
Copy link
Contributor Author

skrobul commented Jul 7, 2022

@Claudio1L make sure that you that the old javascript is not cached. This means:

  • Remove custom_components/webrtc/www/webrtc-camera.js.gz
  • If you are using HA from the browser, do a hard refresh multiple times (Ctrl+Shift+r on chrome) - instruction for other browsers
  • If you are using HA client on the android mobile phone, kill/restart the application
  • if the iOS app, reset the frontend cache. Side bar> app configuration > debugging>reset frontend cache

This process will not be needed if this gets merged and new version is released.

@nao-pon
Copy link

nao-pon commented Jul 7, 2022

@skrobul Thanks a lot!!

The camera feed has been shown again! I rewrote the "version" in manifest.json to "v2.3.0.1" to ensure a js reload and then restarted HA.

EDITED: Changed to "v2.3.0.1" instead of "v2.3.1" so that it will not be the same as future versions.

@markfrancisonly
Copy link

looks like a fix for version 2022.7 but the the code changes do not appear to be backwards compatible. the js patch breaks functionality in 2022.6

@vmakeev
Copy link

vmakeev commented Jul 7, 2022

@skrobul Thank you, this quickfix works for 2022.7
@nao-pon Changing "version" in the manifest is a nice idea too

@skrobul
Copy link
Contributor Author

skrobul commented Jul 7, 2022

looks like a fix for version 2022.7 but the the code changes do not appear to be backwards compatible. the js patch breaks functionality in 2022.6

Yeah, that's what I was afraid of - thanks for checking this. When I get some spare time, I will have a look to see if this can be adjusted to detect versions.

@markfrancisonly
Copy link

adjusted to detect versions

Would be best, although I'm not a fan of carrying backwards code forward indefinitely, it's early to make a break.

I tried 2022.7, saw broken camera views and was super excited to see your fix, but an important camera lux sensor I wrote broke in 2022.7 due to a opencv library issue related to python 3.10 and decided to rollback to 2022.6

@skrobul
Copy link
Contributor Author

skrobul commented Jul 7, 2022

@markfrancisonly added version check in 8f05746 - can you try it when you get a spare moment?

Copy link

@markfrancisonly markfrancisonly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested that changes create backwards compatibility to 2022.6

@besiktas97
Copy link

@Claudio1L make sure that you that the old javascript is not cached. This means:

  • Remove custom_components/webrtc/www/webrtc-camera.js.gz
  • If you are using HA from the browser, do a hard refresh multiple times (Ctrl+Shift+r on chrome) - instruction for other browsers
  • If you are using HA client on the mobile phone, kill/restart the application

This process will not be needed if this gets merged and new version is released.

This fix didn't work for me. I even deleted webrtc and upload all files again with a restart. Don't have the webrtc-camera.js.gz file.
Did also a delete caching from webbrowser and refreshed it. Not working with a webbrowser nor with iOS dedicated app after closing it.

@skrobul
Copy link
Contributor Author

skrobul commented Jul 8, 2022

This fix didn't work for me. I even deleted webrtc and upload all files again with a restart. Don't have the webrtc-camera.js.gz file.
Did also a delete caching from webbrowser and refreshed it. Not working with a webbrowser nor with iOS dedicated app after closing it.

Does your browser see updated webrtc-camera.js? On chrome/chromium this can be checked by right clicking on the page -> Inspect -> Sources -> your.host.com -> webrtc -> webrtc-camera.js and looking to see if you have changes from this PR (i.e. let unsignedPath). On Firefox it's Inspect -> Debugger -> Sources. If you don't see this, it means you are still using old copy. For some reason on my machine it took 2-3 hard refreshes (Ctrl+Shift+R).

If you DO see the updated code, but it still does not work then please let me know if there is anything showing up on your javascript console. Also, make sure that you have the ip_ban_enabled: false in your HA config. For troubleshooting also please share which browser version does this happen on.

@besiktas97
Copy link

This fix didn't work for me. I even deleted webrtc and upload all files again with a restart. Don't have the webrtc-camera.js.gz file.
Did also a delete caching from webbrowser and refreshed it. Not working with a webbrowser nor with iOS dedicated app after closing it.

Does your browser see updated webrtc-camera.js? On chrome/chromium this can be checked by right clicking on the page -> Inspect -> Sources -> your.host.com -> webrtc -> webrtc-camera.js and looking to see if you have changes from this PR (i.e. let unsignedPath). On Firefox it's Inspect -> Debugger -> Sources. If you don't see this, it means you are still using old copy. For some reason on my machine it took 2-3 hard refreshes (Ctrl+Shift+R).

If you DO see the updated code, but it still does not work then please let me know if there is anything showing up on your javascript console. Also, make sure that you have the ip_ban_enabled: false in your HA config. For troubleshooting also please share which browser version does this happen on.

Its working now! It didnt auto updated the webrtc-camera.js file when I checked with inspection on Google Chrome.
I have manually edited the js file with the changes. Restarted HA, deleted the frontend cache on the iOS dedicated app and its now working. Will check it out tonight when I am home on my wallmounted ipad if its also working there, but I guess that must be fine. Thanks skrobul!

@skrobul
Copy link
Contributor Author

skrobul commented Jul 8, 2022

Restarted HA, deleted the frontend cache on the iOS dedicated app and its now working

Awesome, I've updated the instructions with that - hopefully the steps are correct - don't have any iDevices to test on.

@lelemm
Copy link

lelemm commented Jul 8, 2022

It worked! thanks!

It was hard to get rid of the cache for some reason.
I had to do this way:
F12 to open dev tools on chrome
Settings -> Network -> Disable cache (while DevTools is open).
Then I had to hold the refresh page button and select "Empty Cache and hard refresh".

After logging again into HA, WebRTC worked!

@smilexth
Copy link

smilexth commented Jul 9, 2022

Perfect shot!

@ronaldvdmeer
Copy link

So, any news on merging it into master so that people can start updating?

@calisro
Copy link

calisro commented Jul 10, 2022

It looks like the backward compatibility check breaks the create_link service. From debug tools in the browser, we see this now.

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'haVersion')
at WebRTCCamera.initMSE (webrtc-camera.js:67:61)
at WebRTCCamera.connectedCallback (webrtc-camera.js:781:24)
initMSE @ webrtc-camera.js:67
connectedCallback @ webrtc-camera.js:781
await in connectedCallback (async)
(anonymous) @ embed?url=test:39

@dietlman
Copy link

where do I get the updated webrtc-camera.js file? I didn't see any difference on the one I could download here from the one I am using. also I can't see the "let unsignedPath" entry in my file..

@besiktas97
Copy link

where do I get the updated webrtc-camera.js file? I didn't see any difference on the one I could download here from the one I am using. also I can't see the "let unsignedPath" entry in my file..

Look in this thread (scroll up) under the section commits. There you will see which lines are deleted and added. You can also edit your file insteed of copy the file.

@dietlman
Copy link

dietlman commented Jul 11, 2022 via email

@skrobul
Copy link
Contributor Author

skrobul commented Jul 11, 2022

@calisro thanks - I have added a check in 3b50272, but checked that the unmodified version does not seem to work in the 2022.6 so not sure what's the root cause. Which version did you upgrade from?

@smilexth
Copy link

where do I get the updated webrtc-camera.js file? I didn't see any difference on the one I could download here from the one I am using. also I can't see the "let unsignedPath" entry in my file..

wget https://raw.githubusercontent.com/AlexxIT/WebRTC/8f057469562900eaed34ce271d85476a1edeb64a/custom_components/webrtc/www/webrtc-camera.js -O /root/config/custom_components/webrtc/www/webrtc-camera.js

then

rm /root/config/custom_components/webrtc/__pycache__

@calisro
Copy link

calisro commented Jul 12, 2022

@skrobul I've came from each point release. I am on 2022.7.3 now but came from the 2022.6 series. I can try that change...

EDIT: That worked in chrome for me. I'll test it in my other clients like pipup and others as well. thanks!

@AlexxIT AlexxIT merged commit 6176890 into AlexxIT:master Jul 12, 2022
@AlexxIT
Copy link
Owner

AlexxIT commented Jul 12, 2022

Thanks!

@Delta1977
Copy link

@AlexxIT can you make a new release? so all users get this patch automaticly

@AlexxIT
Copy link
Owner

AlexxIT commented Jul 13, 2022

I rewrote the authorization check on the server side. This is better than check the HA version on the client.

const needsParameterSigning = (hass.connection && hass.connection.haVersion >= '2022.7.0b0');

"2022.7.0" >= "2022.7.0b0" // false
"2022.10.0" >= "2022.7.0b0" // false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebRTC stops working on HA 2022.7.0b0