Moosh problem with Redis

Moosh problem with Redis

by Alain Raap -
Number of replies: 10

Our Redis server is protected for security with a password.
When I try to run a Moosh (1.21) command I get the following error:

Error code: generalexceptionmessage

  • line 297 of /moosh/moosh.php: RedisException thrown
  • line 297 of /moosh/moosh.php: call to session_start()

!!! Uitzondering - NOAUTH Authentication required. !!!

The session_redis_auth parameter is configured in the config.php of Moodle, and we're using Moodle 4.1.15

How can I get Moosh working with a protected Redis server?

Average of ratings: -
In reply to Alain Raap

Re: Moosh problem with Redis

by Ken Task -
Picture of Particularly helpful Moodlers

I don't run what you run, but how are you issuing moosh commands?

Moosh help shows a couple of options for running as a user:

-u, --user=
Moodle user, by default ADMIN

-n, --no-user-check
Don't check if Moodle data is owned by the user running script

Also, there is an option for running moosh from a config file .... maybe running a special moodle config file without references to redis?

'SoS', Ken

In reply to Ken Task

Re: Moosh problem with Redis

by Alain Raap -
I run Moosh in the Moodle directory with the user of the webserver, so it should find the Redis settings (and password) in the config.php of Moodle
It would be strange if an extra config file is necessary to run Moosh, I know you can create one but I don't use it.
In reply to Alain Raap

Re: Moosh problem with Redis

by Ken Task -
Picture of Particularly helpful Moodlers

"... should find ..." ... well, evidently not or you wouldn't be getting such an error?   So how about sharing one moosh command you are using - literally?

Comment: I use -n as root user of the system and don't seem to have any issues with the moosh commands I run (I don't run them all).

'SoS', Ken

In reply to Ken Task

Re: Moosh problem with Redis

by Alain Raap -
Hi Ken,

This is a simple example I run Moosh with the webserver user, with -n as root user I get the same error:

sudo -u www-data /usr/local/bin/moosh -v info
Default exception handler: Uitzondering - NOAUTH Authentication required. Debug:
Error code: generalexceptionmessage
* line 297 of /moosh/moosh.php: RedisException thrown
* line 297 of /moosh/moosh.php: call to session_start()

!!! Uitzondering - NOAUTH Authentication required. !!!
In reply to Alain Raap

Re: Moosh problem with Redis

by Ken Task -
Picture of Particularly helpful Moodlers
In reply to Ken Task

Re: Moosh problem with Redis

by Alain Raap -
I have started a discussion on Tomasz Muras his own website, don't know if he'll read it or someone else:

https://github.com/tmuras/moosh/discussions/507
In reply to Alain Raap

Re: Moosh problem with Redis

by Ken Task -
Picture of Particularly helpful Moodlers

moosh, like other Moodle plugins, is sensitive to versions.

Core of your site is a 4.1.x

https://moodle.org/plugins/pluginversions.php?id=522

shows 2 moosh versions that are supposed to be compat.

'SoS', Ken

In reply to Ken Task

Re: Moosh problem with Redis

by Alain Raap -
I tried both versions, 1.21 gives the NOAUTH error, 1.25 doesn’t work at all.
In reply to Ken Task

Re: Moosh problem with Redis

by Alain Raap -
I found this workaround, commented out 3 lines of code in moosh.php and it worked again:

// if (session_status() !== PHP_SESSION_ACTIVE) {
// session_start();
//}
In reply to Alain Raap

Re: Moosh problem with Redis

by Ralf Klein -
I have another suggestion for those who get in trouble with the following message (came up during python based bash calls):

"MOOSH result: PHP Warning: session_set_save_handler(): Session save handler cannot be changed when a session is active in /var/www/moodle/lib/classes/session/redis.php on line 243"

simply use moosh switch "-o session_handler_class=unset"
Example:
sudo -u www-data moosh -o session_handler_class=unset cohort-create -i KFZ251 "KFZ251"
Average of ratings: Useful (1)