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 ·
7 Answers
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.


6 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 ·
Show more comments
Hi @RBDawg,

This looks like the same cause for you?

0 Likes 0 ·
Show more comments
stefan-db avatar image
stefan-db answered ·

Same problem here but no '+' in my email and also no gmail.

1 comment
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 ·

This issue likely isn't specific to gmail. It looks like the error occurs because HTML escaping is applied when it shouldn't be. If that's the case, then any special character in an email address would cause the same issue. There are quite a few characters allowed by the RFCs (https://stackoverflow.com/questions/2049502/what-characters-are-allowed-in-an-email-address).

If you look at your email address in the VRM Account section at the bottom of the Settings screen, do you see any % characters?

0 Likes 0 ·
stefan-db avatar image
stefan-db answered ·

Don't understand where to look exactly but my email has on small latin letters.

1 comment
2 |3000

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

rbdawg avatar image rbdawg commented ·
Log in to VictronConnect, then go to the settings page. At the bottom you will find your account name. If your unusual character had been replaced by %xx (%2B for a plus sign), that is the same problem.
0 Likes 0 ·
stefan-db avatar image
stefan-db answered ·

@Guy Stewart (Victron Community Manager)

Is there a solution for this problem?

I still get that same error MQTT-RPC like mentioned higher. Result is that the Node-Red flows block & I have to reboot the cerbo to be able to restart Node-Red.

There are no faults in de Node Red flows as they run every 10 min perfect but somehow during the night that error comes.

This morning I saw that the flow stopped on the VRM API demand (request was still mentioned on the screen) but flow was stopped there.

2 |3000

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

stefan-db avatar image
stefan-db answered ·

Now I get this fault ...

1716369868202.png


1716369868202.png (77.6 KiB)
2 |3000

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

John kilco avatar image
John kilco answered ·

I have the same issue as above (The same error message).. I know my batteries are being charged, no problems with my email address..

My 250/100 on ve.direct just doesn't appear on my ccgx. Every thing else works, all firmware is updated


Any ideas

2 |3000

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

John kilco avatar image
John kilco answered ·

I am very sorry.. I have sorted my problem. Latest firmware seems to deal with all of the issues I am an idiot...... it was a loose battery cable and the ve.direct fell out... so the advice is check all cable connections and make sure they are FIXED

2 |3000

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

Related Resources