weechat-matrix
weechat-matrix copied to clipboard
matrix: disconnected from server
This is an extremely annoying problem I've been experiencing since I picked up "weechat-matrix" as my native Matrix client again. Every few seconds it disconnects, just to wait 10 seconds before reconnecting. I also don't know what the cause is since I'm the only person on my homeserver (which got enough resources).
There are a couple of closed issues which explain how to mitigate this: https://github.com/poljar/weechat-matrix/issues/27#issuecomment-584323279 https://github.com/poljar/weechat-matrix/issues/69#issuecomment-478168413 https://github.com/poljar/weechat-matrix/issues/123#issuecomment-543573043 https://github.com/poljar/weechat-matrix/issues/195#issuecomment-635544297
server {
listen 80;
server_name gravitation.me;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name gravitation.me;
ssl_certificate /etc/letsencrypt/live/gravitation.me/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/gravitation.me/privkey.pem;
location /_matrix {
proxy_pass http://localhost:8008;
proxy_set_header X-Forwarded-For $remote_addr;
# Nginx by default only allows file uploads up to 1M in size
# Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
client_max_body_size 10M;
}
}
# This is used for Matrix Federation
# which is using default TCP port '8448'
server {
listen 8448;
server_name gravitation.me;
ssl_certificate /etc/letsencrypt/live/gravitation.me/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/gravitation.me/privkey.pem;
location / {
proxy_pass http://localhost:8008;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
This is my nginx configuration for Matrix. Sorry if this sounds like a stupid question, but which one of the three is the reverse proxy? Which part do I have to alter? I just copied and pasted the commands since this is my first time using nginx.
In your second server
block, place a http2_max_requests N;
directive, where N
is the number of HTTP requests you want to allow over a single HTTP2 connection before it is closed. On our own server, we set this to 100000 and it's been working fine.
In your case, the section would then look like this:
server {
listen 443 ssl;
server_name gravitation.me;
http2_max_requests 100000;
ssl_certificate /etc/letsencrypt/live/gravitation.me/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/gravitation.me/privkey.pem;
location /_matrix {
proxy_pass http://localhost:8008;
proxy_set_header X-Forwarded-For $remote_addr;
# Nginx by default only allows file uploads up to 1M in size
# Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
client_max_body_size 10M;
}
}
I've encountered exactly the same problem, but every solution I found here was related to Nginx. Since my homeserver is using Apache Reversed Proxy, I did some digging and found this same solution could be applied for Apache using these steps:
-
If you're using a "default" Apache 2 setup with reversed proxy, HTTP2 should already be enabled and the module mpm_prefork should be enabled.
-
Disable mpm_prefork and enable mpm_worker
sudo a2dismod mpm_prefork
sudo a2enmod mpm_worker
-
To Increase max. number of connections:
sudo pico /etc/apache2/mods-enabled/mpm_worker.conf
-
There should be some lines there:
<IfModule mpm_worker_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>
- Replace these by:
<IfModule mpm_worker_module>
ServerLimit 250
StartServers 10
MinSpareThreads 75
MaxSpareThreads 250
ThreadLimit 64
ThreadsPerChild 32
MaxRequestWorkers 8000
MaxConnectionsPerChild 10000
</IfModule>
- Restart Apache & Synapse
sudo systemctl stop matrix-synapse
sudo /etc/init.d/apache2 restart
sudo systemctl start matrix-synapse
- Reload the weechat-matrix script in weechat. The disconnection problem should be gone now.