Skylar-Tech / node-red-contrib-matrix-chat

Matrix chat server support for Node-RED
GNU General Public License v3.0
31 stars 10 forks source link

Trouble with matrix-server-config #66

Closed saket424 closed 1 year ago

saket424 commented 1 year ago

@skylord123 I am new to this project and am using nodered 3.0.2 I am successfully able to create a matrix user using the shared registration secret node

I am unable to save the access token and device id into the matrix-server-config node. When I try to save the data and deploy the list users node, the matrix-server-config node doesn't have any data after the deploy. Can you give me a clue of what I may be doing wrong and a hint for how to debug it

Thanks in advance

saket424 commented 1 year ago

I am seeing a http POST like this going to a matrix-chat endpoint inside nodered instead of to synapse. Can anyone provide any insights into what i may be doing wrong?

curl 'https://ody6.example.io:1880/matrix-chat/login' \ -H 'Accept: application/json, text/javascript, /; q=0.01' \ -H 'Accept-Language: en-US,en;q=0.9' \ -H 'Connection: keep-alive' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ -H 'Origin: https://ody6.example.io:1880' \ -H 'Referer: https://ody6.example.io:1880/' \ -H 'Sec-Fetch-Dest: empty' \ -H 'Sec-Fetch-Mode: cors' \ -H 'Sec-Fetch-Site: same-origin' \ -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36' \ -H 'X-Requested-With: XMLHttpRequest' \ -H 'sec-ch-ua: "Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'sec-ch-ua-platform: "Linux"' \ --data-raw 'userId=%40nrb%3Amatrix6.example.io&password=strongpassword&baseUrl=http%3A%2F%2F172.17.0.1%3A8008&displayName=Node-RED' \ --compressed

yields a response

<!DOCTYPE html>

Error
Cannot POST /matrix-chat/login
skylord123 commented 1 year ago

@saket424 Can you check your logs for node-red? Wonder if this is a file permission issue or something else (especially if you run into docker this is a common problem).

sgofferj commented 1 year ago

I'm running into similar problems. I'm running Node RED in docker and I can't fetch the token. In Node RED, I see "Failed to login due to server error communicating with Node-RED". In the browser console, I have first seen POST https://hostname/matrix-chat/login 404. Then I figured that I bent the URLs a little and had set httpAdminRoot: '/edit' and httpNodeRoot: '/'. After temporarily disabling those, I then got the same error in the node configuration but POST https://hostname/matrix-chat/login 401 in the browser console. The Node RED log doesn't show anything relevant with regards to the 401 error.

skylord123 commented 1 year ago

@sgofferj what version of NodeJS & Node-RED are you running?

sgofferj commented 1 year ago

@sgofferj what version of NodeJS & Node-RED are you running?

NR: 3.0.2 Node: 16.16.0 Image: nodered/node-red:latest

saket424 commented 1 year ago

@skylord123 and @sgofferj , I too am using nodered 3.0.2 and nodejs-16

I think the root cause is the matrix-server-config node isn't working and saving the access token specified

I am running nodered in elevated root permission mode since it may need access to raw /dev devices. So I doubt it is a file permissions issue

skylord123 commented 1 year ago

@sgofferj @saket424 thanks for responding! I will check this out and get back to you guys. I'm running NodeJS 14 right now on my home server and it's working. I bet this has to do with NodeJS 16. I have an update I have been working on that will resolve this if that is the case.

saket424 commented 1 year ago

@skylord123 Eagerly waiting for your update and confirmation that you have a fix for nodeJS 16 as you suspect is the case

skylord123 commented 1 year ago

Sorry for taking a while. Been busy with on-call work stuff.

So I tested my new changes on nodejs 12, 14, and 16 and it's working correctly. Before I do a release though there is a couple other fixes people have put in that I will be including. So expect this to be released in the next couple days.

Again, sorry for the wait.

sgofferj commented 1 year ago

No need to apologize for sacrificing your spare time doing unpaid work so total strangers can do some cool stuff! 😉 Thanks for your work!

skylord123 commented 1 year ago

@sgofferj v0.7.0 just landed. Give it a shot and let me know how it goes. Thanks!

sgofferj commented 1 year ago

@skylord123 Awesome! I'll start testing when I'm back from my trip.

saket424 commented 1 year ago

@skylord123 It appears the issue is fixed now with v0.7.0 Thanks for all the updates. I have begun with the newest synapse and element docker images and am using the nginx reverse proxy and nodered 3.0.2 also as docker containers

I am also using https://github.com/oofnikj/docker-openwrt version 21.02.5 running as the controlling docker container for all the other containers. All traffic in and out of the other containers flows through this controlling container

sgofferj commented 1 year ago

Works for me too, even with the bent URLs. Thanks! Any plans to implement cross-verification?

skylord123 commented 1 year ago

Any plans to implement cross-verification?

I have a branch I am working on but haven't had time to touch it recently. I was having some issues doing the verification which may have been fixed in the latest matrix-js-sdk/olm versions so I will have to give it another shot.

I also want to add secret storage support and this looks promising to try out: https://github.com/matrix-org/matrix-js-sdk/issues/2506#issuecomment-1181549021

sgofferj commented 1 year ago

Awesome!