Good day, ladies and gentlemen.
Today I will tell you how to make chat using chatd. And be able to use it through https.
I warn you that all further actions are at your own risk.
So. The first one. in the chat settings specify 127.0.0.1. Yes. this tells chatd to use localhost.
You also need to set the chat server mode. I specified streaming as an update method.
The second one. You will need to configure apache for https proxy.
This is my example for apache vhost config.
Listen your_external_outside_ip:9111
<IfDefine SSL>
<VirtualHost your_domain.somewhere:9111>
ServerName your_domain.somewhere:9111
ServerAdmin root@your_domain.somewhere
SSLEngine on
SSLProxyEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /etc/letsencrypt/live/your_domain.somewhere/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/your_domain.somewhere/privkey.pem
SSLVerifyClient none
SSLProxyEngine on
ProxyRequests off
ProxyPreserveHost on
<Location />
ProxyPass http://localhost:9111/
## ProxyPassReverse http://127.0.0.1:9111/
</Location>
ErrorLog /var/log/apache2/moodle_ssl_error_log
TransferLog /var/log/apache2/moodle_ssl_access_log
CustomLog /var/log/apache2/moodle_ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfDefine>
The third paragraph.
Now you need to make changes to the chat module files with your hands.
directory /home/apache/your_domain_or_somewhere/moodle/mod/chat/gui_sockets
In all files you should replace http: with https:
Next, change chatd.php:
from echo '<a target="empty" href="http://'.$CFG->chat_serverhost.':'.$CFG->chat_serverport.
to echo '<a target="empty" href="https://'.$CFG->chat_serverhost.':'.$CFG->chat_serverport.from "; url=http://$CFG->chat_serverhost:$CFG->chat_serverport/?win=users&".
to "; url=https://$CFG->chat_serverhost:$CFG->chat_serverport/?win=users&".
4. Then, You need to run chatd in the command line:
/usr/bin/php /home/apache/your_domain_or_path_somewhere/moodle/mod/chat/chatd.php --start &Here is an example of how the output should look.
localhost ~ # php /home/apache/your_domain_or_somewhere/moodle/mod/chat/chatd.php --start -v
Moodle chat daemon v1.0 on PHP 7.4.4
[2020-03-30 04:19:55] Setting up sockets
[2020-03-30 04:19:55] Socket opened on port 9111
[2020-03-30 04:19:55] *IMPORTANT* Started Moodle chatd on port 9111, listening socket Resource id #87
[2020-03-30 04:19:55] Polling chats to detect disconnected users
And, restart apache.-----------------------------
And now about the problems.
Somewhere after less than a day, chatd was still running. However, when I tried to enter the chat, it exited with error:
[2020-03-30 20:14:47] Polling chats to detect disconnected users
[2020-03-30 20:16:17] Polling chats to detect disconnected users
[2020-03-30 20:16:25] * IMPORTANT * Safari identified ...
[2020-03-30 20:16:25] Incoming connection from 127.0.0.1:50254
Default exception handler: Error reading from the Debug database: MySQL server has gone away
SELECT * FROM mdl_chat_users WHERE sid =?
[array (
0 => 'blablabla',
)]
Error code: dmlreadexception
* line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
* line 1247 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database-> query_end ()
* line 1587 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database-> get_records_sql ()
* line 1559 of /lib/dml/moodle_database.php: call to moodle_database-> get_record_sql ()
* line 1538 of /lib/dml/moodle_database.php: call to moodle_database-> get_record_select ()
* line 492 of /mod/chat/chatd.php: call to moodle_database-> get_record ()
* line 623 of /mod/chat/chatd.php: call to ChatDaemon-> promote_final ()
* line 1033 of /mod/chat/chatd.php: call to ChatDaemon-> promote_ufo ()
!!! Error reading from database !!!
Exception ignored in shutdown function tool_log \ log \ manager :: dispose: Error reading from database
google says you need to edit mysql settings.
I added the following settings to my.cnf:[mysqld]
wait_timeout = 3600
max_heap_table_size = 2G
tmp_table_size = 2G
Tomorrow I will find out if chatd will fall.