question

edb avatar image
edb asked

VictronConnect VRM tab MQTT-RPC Unable to connect to the RPC broker Error Code: #R2

When I select my Cerbo GX on the VRM tab in Victron connect, I receive the following error: "MQTT-RPC Unable to connect to the RPC broker. Configuring the device is not possible. Error Code: #R2"

The Cerbo GX is connected to VRM with 2 way communication enabled, and is working well. I have 2 mppt controllers, a Smart Shunt connected via VE Direct, and a MultiPlus-II connected via VE Bus. All show up without issue in the VRM web UI. All devices have the latest firmware.

I've tried the following to resolve the issue:

  • using the Android, Mac OS, and Windows VictronConnect apps (all version 6.0.4)
    • earlier versions of the apps also had the same issue
  • logged into VRM and granted access in the apps
  • logged out and back in several times
  • restarted my phone
  • restarted the app on all devices
  • force quit the app on Android
  • cleared app cache on Android
  • cleared app data on Android
  • enabling MQTT on LAN (SSL) (both without and with the "MQTT on LAN (Plaintext)" option also enabled)
    • After enabling each combination, I tried opening VictronConnect, then force quitting the app, clearing cache and reopening it, then again after restarting the Cerbo GX
  • switching my phone exclusively to the mobile network (switching off WiFi)
  • switching my phone exclusively to the mobile network, creating a hotspot and connecting the cerbo to the hotspot (so that nothing was connected to my WiFi network)
  • trying both the Windows PC and Mac when connected to my mobile hotspot
  • following these instructions (https://community.victronenergy.com/questions/155407/mqtt-local-via-mqtt-broker.html) to connect MQTT Explorer. With that connected both to mqtt127.victronenergy.com:8883 and on the local network to port 1883 on the GX's IP, I can successfully receive MQTT messages. This seems to indicate that the GX is successfully producing the messages, and that there aren't any issues with those messages getting through to the Victron cloud broker. Inspecting the messages further, I can see data from both my MPPT controllers, the Smart Shunt, the Multiplus II, and from the GX itself
  • I've logged network traffic from Victron Connect using both Wireshark, and XCode Instruments, and can see network requests being made to vrmapi.victronenergy.com / ec2-3-127-228-28.eu-central-1.compute.amazonaws.com, and to mqtt-rpc.victronenergy.com / ec2-18-198-160-64.eu-central-1.compute.amazonaws.com, both with what looks like a successful TLS 1.2 handshake followed by transmission of some data. Though it's hard to tell if these requests were made at the same moment I attempted to connect to the GX on the VRM tab in VictronConnect.

Does anyone have any idea what might be happening, or any further steps I could take to debug the issue?


screenshot-2024-04-19-at-30237pm.png

screenshot-2024-04-19-at-30240pm.png

screenshot-2024-04-19-at-30242pm.png

VRMVictronConnectMQTTbug report
3 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi @edb,

Can you please do a screen recording?

And also create a service report?

https://www.victronenergy.com/media/pg/VictronConnect_Manual/en/troubleshooting.html#UUID-98bc9211-902b-01a0-96b9-1f314c4d63c5

Once we have both of those I’ll ask R&D to have a look.

0 Likes 0 ·
edb avatar image edb commented ·

On further investigation, it looks like the error appears at the exact moment the app receives a response to the request it makes to mqtt-rpc.victronenergy.com — the request itself succeeds, but VictronConnect doesn't like the response (it's https, so I can't see the data)

0 Likes 0 ·
rbdawg avatar image rbdawg commented ·
I have this same issue. FWIW, I have just updated the Cerbo GX firmware from v3.13 to v3.30, losing the analog inputs, reverted to v3.13, then manually updated to v3.14. The analog inputs are back, but the MQTT-RPC Error R2 persists.
0 Likes 0 ·
1 Answer
edb avatar image
edb answered ·

### Resolution


The issue is caused by a bug in VictronConnect where the app fails to authenticate when the user's email contains "+" (and perhaps other characters). I have worked around the issue by creating a new account without a "+" in the email.


### Diagnosis


I attached Xcode Instruments to the VictronConnect process and profiled it while reproducing the error. I then searche the samples from around the time the error occurred for "error", which showed the following call tree:

screenshot-2024-04-21-at-10938pm.png


From that, we can see that the error-handling code of QMQTT is invoked after receiving something from the network (onNetworkReceived).

I'm not sure exactly which library Victron is using, but the code may be similar to this: https://github.com/emqx/qmqtt/blob/39c3e8af25407e25590b511c1e9387deabe89bac/src/mqtt/qmqtt_client_p.cpp

In any case, a few of the errors centre around authentication, so it was worth digging in further to that as a possible source of issues.

Looking in the Settings section of the app, the "VRM Account" section, it displays my email with the "+" as "%2B" (i.e. it's been HTML-escaped when it shouldn't have been). It's not too much of a stretch to imagine it might have been HTML-escaped server-side, or perhaps client-side soon after receiving it from the server, and that the app was then incorrectly using the escaped version when trying to authenticate to the Victron MQTT broker.

To test this, I created a second account using a different email with no "+" sign, and added it to my installation, which worked perfectly. To rule out an unrelated issue with my original account, I then created a third account, also with a "+" sign, and verified that it too had the same issue as the original account, which it did.


4 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

edb avatar image edb commented ·
@Guy Stewart (Victron Community Manager) , could you please pass this on to R&D?
0 Likes 0 ·
Thanks for the further info, I'll let them know.
0 Likes 0 ·
Hi @RBDawg,

This looks like the same cause for you?

0 Likes 0 ·
rbdawg avatar image rbdawg Guy Stewart (Victron Community Manager) ♦♦ commented ·
Yes, same for me. The gmail address I used to register has +victron appended to the user name. In VictronConnect Settings, the VRM account now shows %2B instead of the + sign. Logging in still works normally. I would prefer not to change my logins. I'm sure there others that use the gmail feature of appending an identifier to the username with a + character, so it would probably be easiest for your support team if gmail compatability is restored. Thanks!
0 Likes 0 ·

Related Resources