SEPIA-Framework / sepia-docs

Documentation and Wiki for SEPIA. Please post your questions and bug-reports here in the issues section! Thank you :-)
https://sepia-framework.github.io/
237 stars 16 forks source link

SEPIA headless client not connecting alongside server on Rpi4 #25

Closed eX00r closed 4 years ago

eX00r commented 4 years ago

I started a new issue, as the feature request might not be the right place for this.

I am running SEPIA server v2.4.1b on a Rpi4 4GB.

I installed as described the headless client and was able to start the server before the client, but I am not able to "configure the client via remote connection". When I run the run.sh script for the client, I can hear his message "...I'll be right there. Just a second.". But then nothing happens. I waited the whole night. The ssh terminal is waiting with this output:

Starting CLEXI server nohup: appending output to 'nohup.out' RPi model: Raspberry Pi 4 Model B Rev 1.1 - Is Pi4: 1 Running SEPIA-Client in 'headless Pi4' mode. Use SEPIA Control-HUB to connect and control via remote terminal, default URL is: ws://[IP]:9090/clexi

The Client Connections Page in the Sepia Control Hub gives me:

CLEXI closed. Reason: 1006 CLEXI error CLEXI connecting...

when I try to connect.

When I run the shutdown script ~/sepia-client/shutdown.sh I get:

sh shutdown.sh Stopping Chromium with SEPIA Stopping Xvfb server It seems no CLEXI server was running DONE.

I have no idea what went wrong. Maybe it is useful to know, I did not change any of the standard variables during setup. And I did no Nginx installation with the main server.

sepia-assistant commented 4 years ago

Hi,

... It seems no CLEXI server was running ... this seems to be the most important info. After installation of the 'headless' client (I need to find a better name for it ^^) you should at least be able to reach the point "ready for setup" even if you have no server at all. This should trigger about 20-30s after "...I'll be right there. Just a second" on a Pi4 or it won't trigger at all.

Can you check the 'nohup.out' file in your ~/clexi folder to see if there is any error preventing CLEXI to start?

fquirin commented 4 years ago

Something I just noticed: Your CLEXI start says nohup.out ... can you check that your start command is nohup node --title=clexi-server.js server.js &> log.out& ... it should write to log.out. Not that the naming was important but it might indicate that something is wrong with your start script.

eX00r commented 4 years ago

Hi,

this is the content of 'nohup.out':

Error: listen EADDRINUSE: address already in use 1*..0.*:XXXX at Server.setupListenHandle [as _listen2] (net.js:1280:14) at listenInCluster (net.js:1328:12) at GetAddrInfoReqWrap.doListen [as callback] (net.js:1461:7) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:61:10) Emitted 'error' event at: at Server.emit (events.js:203:15) at emitErrorNT (net.js:1307:8) at process._tickCallback (internal/process/next_tick.js:63:19) events.js:174 throw er; // Unhandled 'error' event

Error: getaddrinfo ENOTFOUND raspberrypi.local at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26) Emitted 'error' event at: at Server.emit (events.js:203:15) at GetAddrInfoReqWrap.doListen [as callback] (net.js:1458:12) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:17)

And now of course, I see the point: The adress 'already in use' (or better the port) is my openHub system. How do I change this?

@fquirin : I don't get exactly what you mean by "check that your start command is...". Where do I check this? Until now, I started the headless client by sh ~/sepia-client/run.sh

fquirin commented 4 years ago

Where do I check this? Until now, I started the headless client by sh ~/sepia-client/run.sh

If you used the run.sh all should be good. The command is inside this script. Just to be sure I'd recommend to start the script with bash run.sh instead sh, some of the IF-conditions inside might behave strange when using sh O_o.

To edit the CLEXI port you need to change 3 files:

eX00r commented 4 years ago

Ok thanks. now there is still a problem with the last error.

Error: getaddrinfo ENOTFOUND raspberrypi.local at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26) Emitted 'error' event at: at Server.emit (events.js:203:15) at GetAddrInfoReqWrap.doListen [as callback] (net.js:1458:12) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:17)

I the headless client is configured to somehow look for raspberrypi.local, whereas my raspbery runs the openhabian OS, hence openhab.local might be the replacement for raspberrypi.local. But where to change it?

eX00r commented 4 years ago

I replaced the only raspberrypi.local I was able to find in ~/clexi/settings.json with openhab.local. The nohub.out stays the same.

But the content of log.out now shows:

Server with ID 'clexi-123' running at: http://1**.1**.1**.**:7070 Hostname: openhab.local - SSL: false CLEXI Xtensions loaded: 3 /home/openhabian/clexi/node_modules/@abandonware/noble/lib/hci-socket/hci.js:100 this._deviceId = this._socket.bindRaw(deviceId); Error: ENODEV, No such device at Hci.init (/home/openhabian/clexi/node_modules/@abandonware/noble/lib/hci$ at NobleBindings.init (/home/openhabian/clexi/node_modules/@abandonware/nob$ at process.nextTick (/home/openhabian/clexi/node_modules/@abandonware/noble$ at process._tickCallback (internal/process/next_tick.js:61:11)

fquirin commented 4 years ago

It looks like is has problems with the bluetooth module of CLEXI. If you've installed other software on the same RPi there might be some conflicts or maybe the device is deactivated? You can deactivate the BLE module in the CLEXI settings.json, simply remove "ble-beacon-scanner" from the "xtensions" array. If your client complains afterwards you can set "useBluetoothBeacons": false in your ~/clexi/www/sepia/settings.js. Hope it works now :crossed_fingers:

eX00r commented 4 years ago

Thanks. I did both.

Now log.out shows:

internal/modules/cjs/loader.js:800 throw err; SyntaxError: /home/openhabian/clexi/settings.json: Unexpected token ] in JSON a$ at JSON.parse () at Object.Module._extensions..json (internal/modules/cjs/loader.js:797:27) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/home/openhabian/clexi/server.js:11:18) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

Sorry to bother you so much.

fquirin commented 4 years ago

Hi, np. It looks like there is a typo somewhere in the settings.js. Can you double check or post your content. It should look like this:

{
    "hostname": "localhost",
    "id": "clexi-123",
    "idIsPassword": true,
    "port": 8087,
    "ssl": false,
    "logger": {
        "level": "error"
    },
    "xtensions": [
        "clexi-broadcaster",
        "clexi-http-events"
    ]
}
eX00r commented 4 years ago

The content of ~/clexi/www/sepia/settings.js is very different from what you posted. Hence, I guess you mean the content of setting.json which is located at ~/clexi. Here is my content:

{ "hostname": "openhab.local", "id": "clexi-123", "idIsPassword": true, "port": 7070, "ssl": false, "logger": { "level": "error" }, "xtensions": [ "clexi-broadcaster", "clexi-http-events", ] }

Except of the naming of hostname and the comma after "clexi-http-events" I can not see any differences.

eX00r commented 4 years ago

I removed the comma, restarted the run.sh and now my log.out shows only this, but still, the setup does not start. But I can connect through the SEPIA Hub. I will try again tomorrow to start the setup.

Server with ID 'clexi-123' running at: http://***.***.***.**:7070 Hostname: openhab.local - SSL: false CLEXI Xtensions loaded: 2

eX00r commented 4 years ago

I am able to connect to the clexi server after rebooting. But it does not start the setup process nor does it digest ping all or call login user [user-ID] password [user-pwd].

Maybe I have to stop the clexi server from starting during the reboot process, but how?

I am referring to the comment:

You might have to adjust the start-up process of the Pi a little bit though to make sure the server starts before the client tries to login thinking

which was made here: https://github.com/SEPIA-Framework/sepia-docs/issues/9

fquirin commented 4 years ago

I guess you mean the content of setting.json

correct, sorry ;-)

Maybe I have to stop the clexi server from starting during the reboot process, but how?

Actually the setup process should start without any server running. Only after you've successfully logged in to SEPIA the order will play a role during reboot.

Sooo, we are another step further lets see. CLEXI is running and you can connect, thats good :-) but no connection from the SEPIA client to CLEXI, thats not good :-( Do you hear the "ready for setup" sound? Can you please double-check that you have the correct CLEXI URL in ~/clexi/www/sepia/settings.js? Looking at your CLEXI settings it should be something like "clexiSocketURI": "ws://localhost:7070" or "clexiSocketURI": "ws://openhab.local:7070" since this is what you've used as 'hostname'.

eX00r commented 4 years ago

Thanks. I reviewed my settings.js. It had the following content:

/Settings primarily for headless mode and setup (URL parameter: 'isHeadless=tr$ SepiaFW.settings = { headless: { device: { "host-name": "192.168.178.32", "deviceId": "o1", "deviceLocalSiteData": { "location": "home", "type": "room", "name": "unassigned", "index": "" }, "en-voice": "", "de-voice": "" }, user: { "clexiSocketURI": "ws://localhost:7070", "clexiServerId": "clexi-123", "clexiConnect": true, "useRemoteCmdl": true, "speech-voice-engine": "sepia", "speech-asr-engine": "native", "speech-websocket-uri": "ws://localhost:20741/stt/socke$ "useGamepads": true, "useBluetoothBeacons": false, "useBluetoothBeaconsInAoModeOnly": false, "useWakeWord": false, "autoloadWakeWord": false, "allowWakeWordDuringStream": false, "activeSkin": "2", "proactiveNotes": false, "autoGPS": false }, location: { "latitude": "", "longitude": "" }, broadcast: { "state": true, "login": true, "speech": true } } };

I changed "host-name": "openhab.local" "clexiSocketURI": "ws://openhab.local:7070" "speech-websocket-uri": "ws://openhab.local:20741/stt/socket",

Restarted with bash ~/sepia-client/run.sh. I hear the "...I'll be right there. Just a second." Message, but again, nothing happens afterwards. I am still able to connect through the Sepia Hub (client connections), but can not ping it nor start setup.

Maybe my microphone is a problem? It is recognized (lsusb) but I am not sure if it is set as standard. Edit: I tested the Mic. It is recognized and recording.

sepia-assistant commented 4 years ago

Even if nothing works (mic, server, etc.) the client should still try to enter setup mode and notify you by saying "ready for setup" :-( Either it is trying to play the sound and something else on your RPi is messing with the audio system or it is already logging in with another account ... but in both cases it should still connect to CLEXI. Can you run ~/sepia-client/setup.sh and check if the client is in 'headless' or 'pseudo-headless' mode? If you have a monitor that could be connected to your RPi you could use the 'pseudo-headless' mode to visually debug the client.

eX00r commented 4 years ago

ok I connected to a screen and started the sepia-client in 'pseudo-headless' mode. It says it is running. Not more or less.

Am I missing something? Is the nginx necessary?

sepia-assistant commented 4 years ago

It says it is running

Do you mean you can see the SEPIA client and it is showing your "home screen"? Or do you see only the login box? Can you open the settings page 1 and check if the CLEXI control indicator is green?

Is the nginx necessary?

Not for the setup step if you can still reach CLEXI from another machine (openhab.local:7070). I usually prefer to use it and let CLEXI run via 'localhost'.

I'm sorry this is taking so long to debug :-| it's a bit tricky to find the problem when walking "of the trail".

eX00r commented 4 years ago

No worries. To be honest, I am happy you are still up helping me to get this sorted out.

Ok let's agree on a step-by-step process for the headless mode:

  1. I attached the raspberry pi to a screen and to a keyboard.
  2. I start the SEPIA server (cd ~/SEPIA | bash run-sepia.sh)
  3. cd ~/sepia-client/
  4. bash setup.sh
  5. I set the client to [3] 'pseudo-headless'
  6. bash run.sh from the PI terminal directly

It returns in the terminal:

Starting CLEXI server RPi model: Raspberry Pi 3 Model B Rev 1.1 - Is Pi4: 1 Running SEPIA-CLIENT in 'pseudo-headless' mode- Use SEPIA Control-HUB to connect and control via remote terminal, default URL is: ws://[IP]:9090/clexi

I am able to connect via the client-connections page. It shows a green dot next to the URL (ws://openhab.local:7070/clexi)

The remote terminal after clicking connect shows:

CLEXI server says welcome. Info: {"id":"clexi-123","version":"CLEXI Node.js server v0.8.1","xtensions":{"clexi-broadcaster":{"active":true},"clexi-http-events":{"active":true}}}

After typing ping all into the message field of the remote terminal (message type is set to SEPIA Client) it shows:

Broadcaster response: "sent" Broadcaster event: {"broadcast":{"name":"sepia-client","data":{"ping":"all"}}}

No answer from the client.

From an external machine I can access openhab.local:7070 within the same network and I see a CLEXI Test page.

Do you mean you can see the SEPIA client and it is showing your "home screen"? Or do you see only the login box? Can you open the settings page 1 and check if the CLEXI control indicator is green?

I don't know if I get this right. Where can I see the home screen? I am on a terminal at the PI.

Is it a problem, if the hostname openhab.local is also used by OpenHab system? If I open it in a browser without specifying a port I can see my Welcome to nginx! page, telling me it is up and working.

sepia-assistant commented 4 years ago

No worries. To be honest, I am happy you are still up helping me to get this sorted out.

I expect this will be a popular configuration (server + client on same Pi) so I'm pretty interested in finding out whats going on ;-)

I don't know if I get this right. Where can I see the home screen? I am on a terminal at the PI.

I think we are getting closer to the root of the problem. In 'pseudo-headless' mode the client should open on the screen and show either the login-box or the home screen/chat-window. It looks like the client is not starting at all (although it says "Running SEPIA-Client in 'pseudo-headless' mode") :-( Looking at the run.sh I just might have found a part of the issue. The [localhost:8080] is unfortunately hardcoded here :-|

elif [ "$is_headless" -eq "2" ]; then
    echo "Running SEPIA-Client in 'pseudo-headless' mode. Use SEPIA Control-HUB to connect and control via remote terminal, default URL is: ws://[IP]:9090/clexi"
    chromium-browser --user-data-dir=$chromedatadir --alsa-output-device=default --allow-insecure-localhost --autoplay-policy=no-user-gesture-required --disable-infobars --enable-features=OverlayScrollbar --hide-scrollbars --kiosk 'http://localhost:8080/sepia/index.html?isApp=true&isHeadless=true' >/dev/null 2>&1

Do you see some flickering on the screen when the client is supposed to start? Actually I'd expect to see a "page not found" screen instead of return to terminal. Can you try to run basic Chromium from terminal: chromium-browser ?

eX00r commented 4 years ago

Ok cool. So let's go forward.

If I do chromium-browser I get:

[1926:1926:0319/092138.645313:ERROR:browser_main_loop.cc(584)] Failed to put Xlib into threaded mode. (chromium-browser-v7:1926): Gtk-WARNING **: 09:21:38.647: cannot open display:

I found this: https://www.ketzler.de/2017/12/installing-chromium-on-raspberry-pi-without-desktop/

And if I do xinit chromium-browser I get:

xinit chromium-browser

X.Org X Server 1.20.4 X Protocol Version 11, Revision 0 Build Operating System: Linux 4.15.0-48-generic armv8l Raspbian Current Operating System: Linux openhab 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l Kernel command line: coherent_pool=1M 8250.nr_uarts=1 cma=64M cma=256M video=HDMI-A-1:1920x1080M@60,margin_left=48,margin_right=48,margin_top=48,margin_bottom=48 smsc95xx.macaddr=DC:A6:32:4F:D9:5E vc_mem.mem_base=0x3f000000 vc_mem.mem_size=0x3f600000 dwc_otg.lpm_enable=0 root=PARTUUID=dc17eac9-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait Build Date: 05 June 2019 12:49:54PM xorg-server 2:1.20.4-1+rpt1 (https://www.debian.org/support) Current version of pixman: 0.36.0 Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/home/openhabian/.local/share/xorg/Xorg.0.log", Time: Thu Mar 19 09:26:23 2020 (==) Using system config directory "/usr/share/X11/xorg.conf.d" (EE) Fatal server error: (EE) xf86OpenConsole: Cannot open virtual console 2 (Permission denied) (EE) (EE) Please consult the The X.Org Foundation support at http://wiki.x.org for help. (EE) Please also check the log file at "/home/openhabian/.local/share/xorg/Xorg.0.log" for additional information. (EE) (EE) Server terminated with error (1). Closing log file. xinit: giving up xinit: unable to connect to X server: Connection refused xinit: server error

FYI: I don't have any Window-Manager or GUI installed.

sepia-assistant commented 4 years ago

I thought about this again and I think we have to separate problems now.

Since I assume you want to use the headless try this:

The second option (probably easier to debug):

I don't have any Window-Manager or GUI installed

The SEPIA client comes with openbox, a minimalistic window manager :-)

[EDIT] After you've modified the run.sh you might need to delete the folder ~/sepia-client/chromium since there might be some localhost:8080 configurations already stored.

[EDIT2] I just realized that you might get access rights issues for your microphone when using openhab.local:7070 instead of localhost:7070 for CLEXI :-( I remember now that this was one of the reasons not to change the CLEXI URL and use Nginx for external connections.

eX00r commented 4 years ago

Ok.

I went with the second option. Kept pseudo headless mode. Modified all 'localhost:8080' to 'openhab.local:7070' Removed /chromium Executed startx

Now I can see the client gui on the display attached to the Pi.

Now when I go to the SEPIA HUB client connections on another machine and connect to the clexi server I can broadcast and connect to the client. On the Pi Display I can see it interacting. But there is no speech and no setup starting.

EDIT: Within the client I can connect to the SEPIA Server but as you suspected, it says Microphone not recognized or access denied.... Wierdly it also does not play any sounds for example when I start a radio station.

Just in case the output of remote terminal:

Broadcaster event: {"broadcast":{"client":"o1_chrome_app_v0.21.0","deviceId":"o1","msg":"Hello World"}}

sepia-assistant commented 4 years ago

Can you check these lines in your run.sh to see if they were changed to the correct [host:port]:

if [ -f "$chromedatadir/Default/Preferences" ]; then
    sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' $chromedatadir/'Local State'
    sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' $chromedatadir/Default/Preferences
    sed -i 's/"notifications":{}/"notifications":{"http:\/\/localhost:8080,*":{"last_modified":"13224291659276737","setting":1}}/' $chromedatadir/Default/Preferences
    sed -i 's/"geolocation":{}/"geolocation":{"http:\/\/localhost:8080,http:\/\/localhost:8080":{"last_modified":"13224291716729005","setting":1}}/' $chromedatadir/Default/Preferences
    sed -i 's/"media_stream_mic":{}/"media_stream_mic":{"http:\/\/localhost:8080,*":{"last_modified":"13224291643099497","setting":1}}/' $chromedatadir/Default/Preferences
fi

If this was not the case please remove ~/sepia-client/chromium again, restart the client, wait until you see SEPIA on the screen then close it and start it a second time. This is required because after you delete the folder it will be recreated on the start and modified on the second start :-/

Wierdly it also does not play any sounds for example when I start a radio station.

This was something I was afraid of :-| The sound system of the RPi is very sensitive to changes. If you have any other software installed on your Pi and it plays with Pulseaudio or Alsa this might break the client sound :-(

eX00r commented 4 years ago

Ok. I modified it to the direct IP instead of openhab.local. The mentioned part now looks like this:

if [ -f "$chromedatadir/Default/Preferences" ]; then sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' $chromedatadir/'Local State' sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]+"/"exit_type":"Normal"/' $chromedatadir/Default/Preferences sed -i 's/"notifications":{}/"notifications":{"http:\/\/localhost:8080,":{"last_modified":"13224291659276737","setting":1}}/' $chromedatadir/Default/Preferences sed -i 's/"geolocation":{}/"geolocation":{"http:\/\/localhost:8080,http:\/\/localhost:8080":{"last_modified":"13224291716729005","setting":1}}/' $chromedatadir/Default/Preferences sed -i 's/"media_stream_mic":{}/"media_stream_mic":{"http:\/\/localhost:8080,":{"last_modified":"13224291643099497","setting":1}}/' $chromedatadir/Default/Preferences fi

I restarted the client via a terminal through SSH because I do not see a way to restart the client from it's own GUI on the raspberry. Is this possible? I found it is possible to shutdown X with ctrl+alt+backspace. Did that. Restarted with: startx

Now I see the login screen. After a very short time it logs me in with Demo Account automatically. Can I modify that delay or stop it from logging in automatically?

I was successfull loging in with my admin account. Is that right or shall I use a less privileged user for setting up the headless client?

Nevertheless it does not play any sound nor does it accept the microphone. At least I can verfy everything except speech is working because I can type commands and it accepts them (eg to switch on my light).

Will it be more easy if I change the URL of the Raspberry in openhabian from openhab.local to localhost?

I also found your article https://github.com/SEPIA-Framework/sepia-docs/wiki/Set-up-web-browser-to-treat-your-local-IP-as-secure-origin. Is it possible to do this configuration of chromium on the headless client?

fquirin commented 4 years ago

I modified it to the direct IP instead of openhab.local. The mentioned part now looks like this: [CODE]

This looks a bit strange. The parts with http:\/\/localhost:8080 seem to be missing the escape character now \ in your file. Are you using port 7070 or 8080 at the moment?

I've lost a bit track of all the changes that were done to the files now, so maybe it is worth it to start over with the original files and repeat the important changes we found :sweat_smile: . I think we had 2 major points:

Did I miss something? :-) Don't forget to delete ~/sepia-client/chromium once after all the changes and restart the client twice (one time to rebuild the deleted folder and one time to apply the changes to the folder).

I restarted the client via a terminal through SSH because I do not see a way to restart the client from it's own GUI on the raspberry. Is this possible?

Currently working on CLEXI runtime commands for the clients, so I expect the next version will have it :-)

After a very short time it logs me in with Demo Account automatically. Can I modify that delay or stop it from logging in automatically?

The "headless" client will always do this after 8s (or was it 15s?) if no other account is logged in to start the CLEXI connection and wait for setup commands. Only way to prevent this would be to remove the "&isHeadless=true" flag in the URL but I'd only recommend it if you want to setup everything with display and mouse/keyboard/touch.

I was successfull loging in with my admin account. Is that right or shall I use a less privileged user for setting up the headless client?

Since most of the client settings depend on your user account (you can store and restore them on settings page 2) I'd recommend to log in with the user that you're planning to use for this client (plz not the admin ^^).

Will it be more easy if I change the URL of the Raspberry in openhabian from openhab.local to localhost?

openhab.local is totally fine, but we should use localhost where ever possible to keep the "secure context" of the browser.

Is it possible to do this configuration of chromium on the headless client?

There is supposed to be a start parameter for chromium-browser called --unsafely-treat-insecure-origin-as-secure=http://example.com ... but I've never tried it and some people at stack overflow say it was never working for them. What works is to connect display, mouse and keyboard and start chromium with all the parameters given in the run.sh but remove --kiosk. Then you can set up everything as described in the mentioned link. That said I would not recommend to go down this road, it is very likely that this flag will be removed from Chromium entirely at some point and it is already creating very annoying warning banners at every start :-( (which does not really matter if you're not using a display).

eX00r commented 4 years ago

Sorry. I obviously copied the content of run.sh from another place. Mine actually was ok but using the IP instead of localhost.

I agree with you. This got a bit messy now with all the changes and I agree with your steps. I changed everything accoring to your last advice. In particular:

{
        "hostname": "openhab.local",
        "id": "clexi-123",
        "idIsPassword": true,
        "port": 7070,
        "ssl": false,
        "logger": {
                "level": "error"
        },
        "xtensions": [
                "clexi-broadcaster",
                "clexi-http-events"
        ]
}

Mikrofon nicht richtig erkannt oder Zugriff verweigert: Mögliche Ursache: Unsicherer Ursprung (SSL Zertifikat)

Scrolling through the setting of the client I noticed there is not cecction to Clexi and the field for 'CLEXI server' and 'ID' are empty (showing wss://... as suggestion). I changed it to 'ws://openhab.local:7070', pressed the 'Connect to clexi' button and the connection indicator turned green. Now also the conversation button is green but the Microphone error continues.

From the sepia Hub - Client Connections page I now can connect to it and it also answers the 'ping all' with: 'Broadcaster event: {"broadcast":{"client":"o1_chrome_app_v0.21.0","deviceId":"o1","msg":"Hello World"}}'

fquirin commented 4 years ago

checked bluetooth beacon deactivated in ~/clexi/settings.json. Do we have to change the hostname here?

Yes, please try "hostname": "localhost". This will make sure that the client can be loaded in a secure context via http://localhost:7070/sepia/index.html which is essential for the microphone stuff. I'm a bit surprised actually that your client still loads even this was set to "openhab.local" :thinking: ... I'm pretty sure I've tried this once and CLEXI refused localhost access when this was set to anything different.

changed ~/clexi/www/sepia/settings.js to have "clexiSocketURI": "ws://localhost:7070". Same question: Do we also have to change host-name to localhost?

This is the SEPIA server host URL. If your server is on the same machine localhost will work :-) Otherwise you can try the IP of your server..

I also noticed, there is no "en-voice": "" nor "de-voice": ""

This is ok, it just means they will be automatically selected.

restarted twice with 'ctrl+alt+backspace'

Good. Deleted the folder ~/sepia-client/chromium before? ^^

modified ~/sepia-client/run.sh to http:\/\/localhost:7070 everywhere

:+1: and your chromium-browser lines will call http://localhost:7070/sepia/index.html ... correct? This is very important!

eX00r commented 4 years ago

Ok. I changed the hostnames also.

In ~/clexi/settings.json to "hostname": "localhost" in ~/clexi/www/sepia/settings.js to localhost.

And yes. I also did rm - r ~/sepia-client/chromium before restarting twice the pseudo-headless client.

+1 and your chromium-browser lines will call http://localhost:7070/sepia/index.html ... correct? This is very important!

Good you mentioned it. Indeed the chromium lines within the run.sh where still pointing at openhab.local:7070. Changed it to localhost:7070...

And tada! the pseaudo-headless client is able to connect to the server and to access the mic. I can talk to sepia, when I press the button next to the text input field and for example switch on the light with a voice command. Unfortunately the voice Output is no played on the raspberry audio out. But that's not my priority now.

What I would like to achieve first is to be able to use the wakeword to start the headlass client, because I want to detach the Pi from the screen and control it only by voice. Is this possible? EDIT: I managed to do so in pseudo-headless mode. In settings I found Hey Sepia and allowed local/remote wakeword. Looks like the sound output is the only issue left. Thanks so much for your effort!

fquirin commented 4 years ago

And tada! the pseaudo-headless client is able to connect to the server and to access the mic. I can talk to sepia, when I press the button next to the text input field and for example switch on the light with a voice command

Great! :man_dancing: :smile:

Unfortunately the voice Output is no played on the raspberry audio out. But that's not my priority now.

:-( but you can hear the messages "Be right there" and "Ready for Setup"? Does the music radio work?

eX00r commented 4 years ago

:-( but you can hear the messages "Be right there" and "Ready for Setup"? Does the music radio work?

Both does not play. I guess this is a problem with my sound setup. Although I did not change anything but the configurations we where discussing here.

Edit: Seems as soon as a HDMI Device is connected the Alsa setup somehow fails to play sounds. I detached the screen and it works.

fquirin commented 4 years ago

The whole audio system of Linux and especially the RPi is super fragile if you ask me. Every package that installs anything PulseAudio or Alsa related to run properly can and will most likely mess up something else. What was your setup again? RPi4, USB Mic, Speakers via jack cable? Any other hardware connected?

Something you can try: Remove the --alsa-output-device=default flag from the chromium-browser start command.

eX00r commented 4 years ago

What was your setup again? RPi4, USB Mic, Speakers via jack cable? Any other hardware connected?

No that's it.

Can you let me know how I should start the client in headless mode if no screen attached? So far I started SEPIA Server with bash run-sepia.sh and after that in ~/sepia-client bash run.sh. Now I can hear the Hello friend, I'll be right there, just a second message, but nothing else again. The SSH Terminal is kind of stuck at:

Starting CLEXI server RPi model: Raspberry Pi 4 Model B Rev 1.1 - Is Pi4: 1 Running SEPIA-Client in 'headless Pi4' mode. Use SEPIA Control-HUB to connect and control via remote terminal, default URL is: ws://[IP]:9090/clexi

Meaning it does not go back to the input. Weirdly I can not connect via the SEPIA Hub to the clexi server. Which was possible, when I started with pseudo-headless client earlier.

fquirin commented 4 years ago

Can you let me know how I should start the client in headless mode if no screen attached? So far I started SEPIA Server with bash run-sepia.sh and after that in ~/sepia-client bash run.sh.

That is exactly how it should be done. Since the run-sepia script waits for all connections to be active before it completes the client should be able to connect after that.

The SSH Terminal is kind of stuck at: [...] Meaning it does not go back to the input

That's actually normal. The Script runs in foreground as long as CLEXI is running, but you can use bash run.sh & if you need the terminal.

Weirdly I can not connect via the SEPIA Hub to the clexi server

That is indeed really weird :confused: . The only thing you've changed is switching from 'pseudo-headless' to 'headless' mode? That should have no effect on CLEXI at all. Can you check ~/clexi/log.out to see if there are any errors?

eX00r commented 4 years ago

~/clexi/log.out is:

Server with ID 'clexi-123' running at: http://127.0.0.1:7070 Hostname: localhost - SSL: false CLEXI Xtensions loaded: 2

sepia-assistant commented 4 years ago

~/clexi/log.out is: [...]

Looks normal.

Weirdly I can not connect via the SEPIA Hub to the clexi server. Which was possible, when I started with pseudo-headless client earlier.

Can you double-check that this still works if you go back to 'pseudo-headless'? At the moment I can't think of any connection between the mode and CLEXI, especially since the CLEXI log does not show any errors. Maybe for some reason the CLEXI server starts and gets closed immediately after that. If you run the SEPIA client shutdown script does it say something about CLEXI?

eX00r commented 4 years ago

I just started another attempt. Started the SEPIA server, started the client in headless mode. And suddenly I got 'I'll be right there, just a second.... Ready for setup'. But then I still can not connect to the client via the SEPIA Hub.

Can you double-check that this still works if you go back to 'pseudo-headless'?

I restarted the Pi and started the Client in pseudo-headless mode with startx. The client starts, I can login and it understands my commands. In the settings of the pseudo-headless clients I can see ws://localhost:7070 as the CLEXI server adress and the indicator next to the connect button shows green. So I assume the client can connect to CLEXI, hence it is up and running. But trying to connect from the SEPIA Hub in another machines browser to the CLEXI server with the same URL gives me:

CLEXI closed. Reason: 1006 CLEXI error CLEXI connecting ...

I have no idea how this is possible.

If you run the SEPIA client shutdown script does it say something about CLEXI?

The output then is:

Stopping Chromium with SEPIA
Stopping Xvfb server
Stopping CLEXI server

DONE.

I noticed when I open openhab.local from another machines browser I am greeted with the ngnix Welcome page. Maybe that's a useful information?

fquirin commented 4 years ago

Oh I think I see the problem, do you use ws://openhab.local:7070 from another machine to access CLEXI?. Since we changed the CLEXI host to localhost you will no longer be able to use this URI but you need to use a proxy address. The default configuration is using Nginx to redirect openhab.local:9090/clexi to localhost:8080. Do you have any reverse proxy running right now?

This should be independent from any 'headless' setting though.

eX00r commented 4 years ago

Do you use ws://openhab.local:7070 from another machine to access CLEXI?

I was using the pseudo-headless client on the Pi on that moment. So the same device on which the SEPIA server is running and also the CLEXI. From pseudo-headless I was able to connect to CLEXI with ws://localhost:7070 but not from my Laptop on which I open openhab.local:20721/tools/ in a browser to get into the SEPIA Hub. Opening the hub with that URl still works, but not connecting to the CLEXI within the hub.

Do you have any reverse proxy running right now?

If I do service nginx status from a remote terminal it confirms it is running. So I guess I need to change the redirect of openhab.local:9090/clexi to localhost:7070? Can you help me with that? :)

What I did so far:

Checked `/etc/nginx/sites-enabled/sepia-client-nginx.conf'.

Changed all proxy_pass http://openhab.local:7070/; to proxy_pass http://localhost:7070/;

Restarted nginx.

Right? Anything else?

And tada: I am able to connect from the SEPIA Hub in the browser of my Laptop.

fquirin commented 4 years ago

from my Laptop on which I open openhab.local:20721/tools/ in a browser to get into the SEPIA Hub. Opening the hub with that URl still works, but not connecting to the CLEXI within the hub.

openhab.local:20721/tools/ will load the HUB from the SEPIA server which doesn't have the same localhost restriction as CLEXI. That would explain why you can still see the page but not necessarily access CLEXI.

I need to change the redirect of openhab.local:9090/clexi to localhost:7070

Correct! :-)

What I did so far: [...] Right? Anything else?

Actually that should be it. After that try ws://openhab.local:9090/clexi from your other machine :crossed_fingers:

[EDIT]

And tada: I am able to connect from the SEPIA Hub in the browser of my Laptop.

Did I miss this or did you just edit your post :grin: ?

eX00r commented 4 years ago

I was editing, while you commented.

I can login, call ping and call test. SEPIA answers.

I restart the pi after finishing 4) Configure the Client via Remote Connection of the instructions.

I want to activate "Hey Sepia". Is it possible that this explanation in the guide is mentioning the wrong settings file?

5) Fine Tuning Optional: Open the CLEXI settings.json file located at ~/clexi/settings.json to tweak your client (e.g. activate "Hey SEPIA"). NOTE: [...]

If I change instead change the content in ~/clexi/www/sepia/settings.js to:

"useWakeWord": true, "autoloadWakeWord": true, "allowWakeWordDuringStream": false, "activeSkin": "2", "proactiveNotes": false, "autoGPS": false

unfortunately the "Hey Sepia" is not waking it up.

fquirin commented 4 years ago

I want to activate "Hey Sepia". Is it possible that this explanation in the guide is mentioning the wrong settings file?

:astonished: yes it is :see_no_evil: ... I'll change that and update the branch soon :-)

unfortunately the "Hey Sepia" is not waking it up.

Settings file looks ok, can you confirm that the microphone is working? You should be able to activate it via the remote trigger button (one of the buttons above the remote terminal input field).

eX00r commented 4 years ago

Tried again today and it works. The mic though might be a bit to insensitive. I'll try another one these days. Only one last question. We deactivated Bluetooth in the very beginning. After all do you think this was necessary? Having it might be useful in the future.

Thanks for all your help and you beautiful work! Looking forward to see this evolve!

fquirin commented 4 years ago

Tried again today and it works.

Great! :grin:

The mic though might be a bit to insensitive

You could try and play a bit with the alsamixer settings to increase input amplification, but this is something I usually only do for audio output.

We deactivated Bluetooth in the very beginning. After all do you think this was necessary?

From what I remember it created some error during CLEXI load. You can always try and reactivate it in the CLEXI settings to see if it works. Currently it is only used for Bluetooth remote trigger which is pretty cool for things like e.g. a Micro:bit but you can also use the HTTP remote trigger as fallback (as demonstrated in the SEPIA HUB client connections page).

Thanks for all your help and you beautiful work! Looking forward to see this evolve!

I'm happy that we managed to get it working! Have fun and see you around! :smiley:

eX00r commented 4 years ago

Thanks. This issue is solved. :)