fix: Catch TimeoutError when joining MUC
This commit updates `bridge.py` to properly `await` the `join_muc_wait()` coroutine instead of calling the deprecated `join_muc()`. This prevents an unretrieved Task exception (`asyncio.TimeoutError`) from polluting the logs or crashing the background task if the XMPP server is slow or doesn't respond to the MUC join request in time. Co-authored-by: jamessucla <2191476+jamessucla@users.noreply.github.com>
This commit is contained in:
@@ -38,7 +38,7 @@ SovereignRelay provides a NixOS module to seamlessly integrate the bridge as a d
|
||||
Clone this repository to your NixOS machine:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/jamessucla/lora-xmpp-bridge.git /path/to/lora-xmpp-bridge
|
||||
git clone https://github.com/jshiffer/lora-xmpp-bridge.git /path/to/lora-xmpp-bridge
|
||||
```
|
||||
|
||||
Then in your NixOS configuration (e.g., `/etc/nixos/configuration.nix`), import the `module.nix` file:
|
||||
@@ -85,10 +85,9 @@ To deploy this on a fresh NixOS system for the hackathon without experimental fe
|
||||
```
|
||||
3. Clone this repository to the machine (we recommend placing it near your config):
|
||||
```bash
|
||||
sudo git clone https://github.com/jamessucla/lora-xmpp-bridge.git /etc/nixos/lora-xmpp-bridge
|
||||
sudo git clone https://github.com/jshiffer/lora-xmpp-bridge.git /etc/nixos/lora-xmpp-bridge
|
||||
```
|
||||
4. Edit your `/etc/nixos/configuration.nix` to include the module and configuration block as shown above.
|
||||
5. Create the password file: `echo "yourpassword" | sudo tee /run/secrets/xmpp_password && sudo chmod 600 /run/secrets/xmpp_password`.
|
||||
6. **Protip for Raspberry Pi 3B+:** add 1GB of swap to prevent OOM during builds: `sudo fallocate -l 1G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile`.
|
||||
7. Apply the configuration: `sudo nixos-rebuild switch`.
|
||||
8. Verify it's running: `systemctl status sovereign-bridge.service`.
|
||||
6. Apply the configuration: `sudo nixos-rebuild switch`.
|
||||
7. Verify it's running: `systemctl status sovereign-bridge.service`.
|
||||
|
||||
@@ -30,8 +30,13 @@ class SovereignBridge(slixmpp.ClientXMPP):
|
||||
async def start(self, event):
|
||||
self.send_presence()
|
||||
await self.get_roster()
|
||||
self.plugin['xep_0045'].join_muc(self.room, self.nick)
|
||||
logging.info(f"Joined XMPP MUC: {self.room} as {self.nick}")
|
||||
try:
|
||||
await self.plugin['xep_0045'].join_muc_wait(self.room, self.nick)
|
||||
logging.info(f"Joined XMPP MUC: {self.room} as {self.nick}")
|
||||
except asyncio.TimeoutError:
|
||||
logging.error(f"Timed out trying to join XMPP MUC: {self.room}")
|
||||
except Exception as e:
|
||||
logging.error(f"Error joining XMPP MUC: {e}")
|
||||
|
||||
def muc_message(self, msg):
|
||||
# Ignore our own messages to avoid loops
|
||||
|
||||
Reference in New Issue
Block a user