MeshCentral: Agents are slow to connect if they are not "local"
Describe the bug Agents are slow to connect if they are not “local”. It takes over 15 minutes for them to connect. Here it is an example:
Mesh Server Connection Error [15]
AutoRetry Connect in 339435 milliseconds
Connecting to: wss://mc.mdonline.ro:443/agent.ashx
Network Timeout occurred...
Mesh Server Connection Error [15]
AutoRetry Connect in 299528 milliseconds
Connecting to: wss://mc.mdonline.ro:443/agent.ashx
Connected.
This is form internal network, from outside it is the same. After it connects the agent stays online for days without any problem. It does not matter if i restart the agent or not…same delay. If in msh i put “local” from internal network it connects instantly. The web server it is working perfectly from inside/outside. I am using an apache2 reverse proxy. Its happening to me since day one…about six months ago …but if I am not loosing my mind it is getting worse with updates…😅 Thank you for your support.
To Reproduce Steps to reproduce the behavior:
- Go to ‘…’
- Click on ‘…’
- Scroll down to ‘…’
- See error
Expected behavior The agent to connect to server in a short amount of time.
Screenshots If applicable, add screenshots to help explain your problem.
Server Software (please complete the following information):
- OS: Ubuntu 24.04.1
- Virtualization: Proxmox
- Network: reverse proxy on another machine, apache2
- Version: 1.1.38
- Node: included in Ubuntu
Client Device (please complete the following information):
- Device: Desktop / Laptop / VM
- OS: Windows / Debian / Ubuntu
- Network: Local / Remote over WAN
- Browser: ?
- MeshCentralRouter Version: [if applicable]
Remote Device (please complete the following information):
- Device: Desktop / Laptop / VM
- OS: Windows / Debian / Ubuntu
- Network: Remote over WAN
- Current Core Version (if known): Nov 21 2022, 3412752687
Additional context Add any other context about the problem here.
Your config.json file
{
"$schema": "https://raw.githubusercontent.com/Ylianst/MeshCentral/master/meshcentral-config-schema.json",
"__comment1__": "This is a simple configuration file, all values and sections that start with underscore (_) are ignored. Edit a section and remove the _ in front of the name. Refer to the user's guide for details.",
"__comment2__": "See node_modules/meshcentral/sample-config-advanced.json for a more advanced example.",
"settings": {
"cert": "mc.mdonline.ro",
"_WANonly": true,
"_LANonly": true,
"_sessionKey": "MyReallySecretPassword1",
"_port": 443,
"_aliasPort": 443,
"_redirPort": 80,
"_redirAliasPort": 80,
"mpsPort": 4433,
"TrustedProxy": "192.168.Y.Z",
"agentping": 30
},
"domains": {
"": {
"_title": "MyServer",
"_title2": "Servername",
"_minify": true,
"certUrl": "https://mc.mdonline.ro",
"_newAccounts": true,
"_userNameIsEmail": true
},
"AmtManager": {
"AdminAccounts": [
{ "user": "admin", "pass": "XXXXX" },
{ "user": "admin", "pass": "XXXXX" }
]
}
},
"_letsencrypt": {
"__comment__": "Requires NodeJS 8.x or better, Go to https://letsdebug.net/ first before trying Let's Encrypt.",
"email": "myemail@mydomain.com",
"names": "myserver.mydomain.com",
"skipChallengeVerification": true,
"production": false
}
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (2 by maintainers)
@mdalacu the was meshagent works with its reconnects is after X miliseconds, it will try to reconnect again, then if it doesnt work, it will wait another random amount of miliseconds before trying again this is why it takes so long for the agents to register back again (looking into if we can change this behaviour later this year)
your logs are showing that your apache is struggling to connect to your meshcentral server
[Fri Jan 10 07:39:09.576121 2025] [proxy:error] [pid 44932] (111)Connection refused: AH00957: HTTPS: attempt to connect to 192.168.1.166:443 (192.168.1.166) failedso this is why your agents arent connectingthe OS you have says Ubuntu, so you can check what port meshcentral is running on by using
lsof -Pniand looking for meshcentral OR usejournalctl -xeu meshcentral.serviceand check what the last logs are to say what port its running onthen you can determine which ports are being using, IF the ports arent port 443 for HTTPS then set those ports in
config.jsonand setaliasPort: 443this tells remote agents to connect back to you on port 443 and NOT the port you specified