Webinar
EMQX Cloud Message History: From MQTT Topics to SQL Queries →
Back

How to Migrate from HiveMQ Cloud Serverless to EMQX Cloud Serverless: A Tested Walkthrough

EMQX Cloud TeamEMQX Cloud Team
Dec 2, 2026Product
How to Migrate from HiveMQ Cloud Serverless to EMQX Cloud Serverless: A Tested Walkthrough

Migrating an MQTT application is more than changing a hostname. Devices and backend applications must move together, permissions must be recreated, and retained values and session state need an explicit plan. This guide walks through a small, repeatable migration using two independent MQTT clients and a controlled pause in publishing.

This is the second post in our series for HiveMQ Cloud Serverless users. In Part 1, we covered what the retirement means and how to choose between EMQX Cloud Serverless and Dedicated Flex. Here, we move a small test workload from a HiveMQ Cloud Serverless cluster to an EMQX Cloud Serverless deployment, move it back, and record what the brokers returned at each step. The ports and console steps below were tested on Serverless only.

Validated scope: HiveMQ Cloud Serverless to EMQX Cloud Serverless, MQTT 5 over secure WebSockets (WSS), username/password authentication, QoS 1 telemetry and commands, a retained configuration value, a ten-message cutover check, and rollback. The screenshots are from test deployments; always substitute your own deployment hostname and credentials. This is a functional rehearsal, not a load benchmark or a zero-downtime guarantee.

HiveMQ Cloud Serverless Free and Pay As You Go reach end of life on December 31, 2026. Keep the original broker available during migration and the rollback window. A deleted Serverless cluster cannot be recreated. See the HiveMQ end-of-life notice.

1. Plan What Must Move

Before you start, work through the Assess step on our HiveMQ Cloud migration page to inventory your clients, credentials, traffic and broker state. This guide picks up from there.

Compare the workload with the current EMQX Cloud Serverless quotas before migration. The values below were verified on December 1, 2026 against the official quotas and limits page; check the live documentation again before production cutover. A scoped subscription such as migration/lab/# is suitable for this test; do not use the bare # client subscription, which is restricted on Serverless. The # pattern can still be used in authorization rules.

QuotaServerless limitMigration check
Concurrent connections1,000Count devices and backend clients, including overlap during cutover.
Cluster connection rate100/sMove clients in batches and add reconnection jitter; avoid synchronized retries.
Subscriptions per client10Count each device and backend client's topic filters before recreating subscriptions.
Publishes per client10/sCompare each publisher's peak rate and pace test traffic below the limit.
Retained messages2,000Inventory retained topics and verify the total before copying values.
Message size1 MBCheck the largest payload, including retained configuration messages.
Topic levels per subscription10Check deep topic trees before recreating subscriptions.
Deployment message rate1,000/sAdd up publishes and fan-out across all clients, not just per client.
Offline message queue1,000 messagesCheck how many messages offline persistent-session clients need held.
Session expiry (MQTT 3.x)2 hours, fixedPlan for MQTT 3.x clients that rely on long-lived persistent sessions.
Serverless deployments per account1 (2 after you add a payment method)A new account can create one Serverless deployment. Adding a payment method allows a second.

What does not move automatically: retained values, subscriptions, persistent sessions, offline queued messages and in-flight QoS state remain on the original broker. Reusing a Client ID on another broker does not transfer any of this state. QoS 1 can produce duplicates, so production applications should use sequence numbers and idempotent processing.

2. Prepare the Target and Connection Details

  1. In HiveMQ Cloud, open your existing Serverless broker and record its hostname, ports and current access credentials. This lab uses Free #1; no second broker is needed.
  2. In EMQX Cloud, create a Serverless deployment in a suitable region and wait for Running. Copy the connection hostname from Deployment Overview.
  3. Review your spend limit and monthly allowances. A $0 spend limit is not unlimited free service: the deployment uses only the monthly free quota (1 million session minutes and 1 GB of traffic) and stops when either runs out. A Serverless deployment with no client connections for 30 days is also stopped automatically. Disconnect idle test clients when finished.
  4. Open MQTTX Web. Use separate browser tabs for the device and backend connections so both can remain connected at the same time.
SettingHiveMQ Source in This LabEMQX Serverless Target
Protocol for this walkthroughwss://wss://
HostYour HiveMQ hostname, without a port or URL pathYour EMQX deployment hostname
WSS port88848084
Path/mqtt/mqtt
MQTT version5.05.0
Session settingsClean Start = true; Session Expiry Interval = 0Clean Start = true; Session Expiry Interval = 0
Keep Alive60 seconds60 seconds
TLS verificationEnabledEnabled; connect using the deployment hostname

Figure 1. MQTTX Web connection form for the EMQX target: wss://, port 8084, path /mqtt, SSL/TLS on (host blurred). This is where most WSS migrations go wrong.

Do not copy the HiveMQ WebSocket port unchanged: this example changes 8884 to 8084. Enable SSL/TLS and keep certificate verification enabled. Browsers use their certificate trust store; for an embedded or desktop client, configure the correct CA trust and SNI hostname. Never disable certificate verification to make a migration pass.

MQTTX Web uses WebSockets; it does not test raw MQTT/TLS on port 8883. If your application uses mqtts://, repeat the same tests with MQTTX Desktop or your actual SDK on port 8883. HTTP API App IDs/Secrets and an endpoint ending in /api/v5 are not MQTT login credentials and are not required here.

3. Verify the HiveMQ Baseline

  1. Open HiveMQ Access Management. Confirm the credential's assigned permission, not just the permissions listed elsewhere on the page. On HiveMQ Serverless, each credential has exactly one permission. In this lab, migration_lab uses the built-in Publish and Subscribe permission, which covers every topic (#). A custom permission you create elsewhere on the page only applies once you assign it to the credential.
  2. Create Hive-device in MQTTX Web using the source WSS settings, Client ID lab-device-001, and your source MQTT username/password. Create Hive-backend in another tab using Client ID lab-backend-001. Use different Client IDs for simultaneous connections on the same broker.
  3. On Hive-backend, click New Subscription, enter migration/lab/device001/telemetry, select QoS 1, and confirm. On Hive-device, subscribe to migration/lab/device001/command with QoS 1. A new subscription may default to QoS 0: change it explicitly.
  4. From Hive-device, publish the telemetry payload below to the telemetry topic with QoS 1 and Retain off. Confirm the exact payload appears on Hive-backend.
{"phase":"source","seq":10,"temperature":23.5}

From Hive-backend, publish the following to the command topic, again with QoS 1 and Retain off. Confirm it appears on Hive-device.

{"phase":"source","command":"ping","seq":11}

Acceptance: both independent receiving clients show the correct topic, payload and QoS. An outgoing green message on the publisher alone is not evidence of subscriber delivery.

Figure 2. Source backend receives device telemetry.

Figure 3. Source device receives the backend command.

4. Recreate Authentication and Topic Permissions

  1. Run this rehearsal on a deployment with no production clients. A new account gets one Serverless deployment, so the simplest option is to rehearse on the deployment that will become your target before any clients move to it. If you already run an EMQX Serverless deployment with live clients, add a payment method and use a second deployment. In the target EMQX console, open Access Control → Authentication. Create the MQTT user migration_lab with a strong password, or use an existing user with that exact username. Re-enter a known source password only if intentionally preserving it; do not assume passwords can be exported from HiveMQ. If you choose a different username, update both the authentication entry and every username-based authorization rule below to match.
  2. Open Authorization → Username. For this isolated lab, add an Allow rule for migration_lab, topic migration/lab/#, action Publish & Subscribe.
  3. Under All Users, add a fallback Deny rule for topic #, action Publish & Subscribe. The All Users → Deny # rule applies to the entire deployment, not just migration_lab. Use it only on a deployment with no production clients; before applying an equivalent fallback rule to an existing deployment, review all current Client ID, Username and All Users rules and assess the effect on other clients.
  4. Reconnect after rule changes and test effective permissions. In production, map every required device/backend topic and use separate least-privilege credentials where appropriate.

This example deliberately narrows the source credential's full-topic access to migration/lab/#. It is not a lossless copy of the source permission model. See EMQX default authorization for rule evaluation and the Serverless fallback-deny approach.

This is the most important difference to get right. On HiveMQ Serverless, a credential can only do what its single permission allows. EMQX's default authorization does the opposite: anything not explicitly denied is allowed. If you recreate only Allow rules, your clients can reach topics they couldn't reach before. On Serverless, the All Users Deny # rule restores allow-only behavior. EMQX checks Username and Client ID rules before All Users rules and applies the first match, so the Allow rule for migration_lab takes effect before the fallback Deny.

Configuration reference: target username Allow rule.

Rule TypeUsernameTopicActionPermission
Usernamemigration_labmigration/lab/#Publish & SubscribeAllow

Configuration reference: All Users fallback Deny rule.

Rule TypeTopicActionPermission
All Users#Publish & SubscribeDeny

Figure 4. The migration_lab user under Access Control → Authentication.

Figure 5. Authorization → Username: the Allow rule for migration_lab on migration/lab/#.

Figure 6. Authorization → All Users: the fallback Deny rule on #.

5. Validate EMQX Before Moving Traffic

  1. Create EMQX-device and EMQX-backend in separate MQTTX Web tabs. Change the hostname, WSS port to 8084, and MQTT credentials to the target values. Keep path /mqtt and MQTT 5; set Clean Start = true and Session Expiry Interval = 0.
  2. Connect both and recreate the command and telemetry subscriptions at QoS 1. Source subscriptions do not appear automatically on the target.
  3. Repeat the two baseline publishes using phase: target. For example, {"phase":"target","seq":1,"temperature":23.5} and {"phase":"target","command":"ping","seq":2}. Check the receiving client in each direction.
  4. With the valid test credential, attempt a subscription to outside/lab/test. Expect an explicit authorization refusal. In this run, MQTTX displayed Not authorized (Code: 135), the MQTT 5 reason code 0x87. Cancel the failed subscription dialog.
  5. With auto-reconnect disabled, create a third connection, EMQX-negative-auth, and connect using an intentionally incorrect password. In this run, the broker rejected the login with MQTT 5 CONNACK reason code 0x86 (Bad User Name or Password). Reconnect with the valid test credential and publish a QoS 1 message to outside/lab/test. The broker rejected it with PUBACK reason code 0x87 (Not authorized), and the connection remained open. Test denied publishes at QoS 1: at QoS 0 there's no acknowledgment, and a denied message is dropped without any error on the client. These checks validate the test account and rules; repeat them with production-equivalent credentials and topic permissions before cutover.

Figure 7. EMQX refusal of an out-of-scope subscription.

6. Copy Retained Configuration Explicitly

  1. On Hive-device, publish {"interval":30,"version":1} to migration/lab/device001/config with QoS 1 and Retain on.
  2. After publishing, add that exact subscription on Hive-backend. Confirm the payload arrives with the Retained marker. A retained value is the latest stored value for a topic, not a message-history archive.
  3. Subscribe to the same configuration topic on the target before copying. Check for any existing value and resolve conflicts before overwriting it. The test target initially had no value for this topic.
  4. Freeze configuration changes for the final copy. Publish the identical topic and payload on EMQX with QoS 1 and Retain on.
  5. Reconnect the target backend with Clean Start = true and Session Expiry Interval = 0, then subscribe again; alternatively, use a fresh verifier client. Confirm the exact payload is delivered with the Retained marker. A live message received while already subscribed is not sufficient proof of retained replay.
  6. Switch Retain off again before the telemetry and command tests.

For production, enumerate all retained topics and preserve payload bytes, intended QoS and expiry semantics. On EMQX Cloud Serverless, the Data Integration Republish action cannot store retained messages; use an MQTT client to publish retained values directly and verify them with a fresh subscription. See the EMQX Cloud Message Republish documentation. On Serverless, the deployment-level retained message expiry is fixed at Never, but a publisher's MQTT 5 Message Expiry Interval is still honored. In our test, a retained message with a 30-second expiry reached a new subscriber at 5 seconds and was gone at 40 seconds. Republishing starts that timer again, so publish an expiring value with its remaining lifetime. Freeze updates for the final reconciliation or design a synchronization mechanism; a static copy becomes stale while the source keeps changing.

Figure 8. Target fresh-subscription verification receives the copied configuration as Retained.

7. Rehearse a Controlled Cutover

  1. Define the rollback trigger first: failed authentication, missing subscriptions/messages, wrong retained configuration, or unacceptable downstream behavior.
  2. Pause device telemetry and backend commands. Record the last source sequence, drain outstanding application work, and decide how source offline/in-flight messages will be recovered.
  3. Disconnect the source device and backend, but keep the broker, credentials and profiles available.
  4. Connect the target backend and establish its subscriptions; then connect the target device and establish its command subscription. Wait until both are ready.
  5. Publish ten messages to the telemetry topic, changing seq from 1 through 10 and keeping Retain off. Use a low rate below the per-client quota.
{"phase":"cutover","seq":1}

On the backend, count received messages with phase: cutover: the unique sequence set must be 1–10. Record missing and duplicate sequence numbers separately. Then send a new command and verify device receipt, and recheck retained configuration on a fresh subscription.

Recorded result: the target backend received all ten unique cutover sequences at QoS 1. The test was manually paced, approximately one message every 2–3 seconds; it is not a throughput measurement. A repeat of the ten-message test delivered all ten with no duplicates. Before resuming publishing, confirm that both target clients remain connected and that all required subscriptions have been granted. If either client repeatedly reconnects, pause the cutover and follow the troubleshooting checklist before proceeding.

Figure 9. Target backend receiving numbered cutover messages (sequences 7 to 10 shown).

8. Prove Rollback and Switch Back

  1. Pause publishing again. Disconnect target device/backend, reconnect the saved HiveMQ profiles and recreate the subscriptions with Clean Start = true and Session Expiry Interval = 0.
  2. Publish fresh telemetry and a command using a distinct phase such as rollback-final. Verify receipt on both independent receiving clients. Reconcile any retained/configuration changes; nothing is copied back automatically.
  3. Repeat the pause, disconnect, connect, subscribe and verify sequence to return to EMQX. Confirm that both target clients connect and their subscriptions are granted before publishing again. If repeated reconnects occur, investigate and resolve the cause before proceeding.
  4. Confirm a new telemetry message and command with phase: final-verified, and the copied retained configuration. These were received successfully after returning to EMQX, using fresh verifier connections (EMQX-backend-verify and EMQX-device-verify).

Figure 10. Final target backend receives retained configuration and new telemetry after the rehearsal.

Figure 11. Final target device receives the backend command.

9. Move Production Clients in Batches

Start with representative real devices and a small canary batch. Move both data ingestion and command routing, not only devices. While devices are split across brokers, a backend connected only to EMQX cannot see telemetry still published to HiveMQ. Use an application-managed dual-broker transition or a separately designed relay if necessary, with duplicate handling and loop prevention. No bridge was used in this lab. Serverless data integration supports only Kafka and HTTP Server connectors, so it can't relay messages from HiveMQ. If you need a broker-side bridge during the transition, Dedicated Flex can subscribe to HiveMQ through its MQTT Broker connector, which needs a NAT gateway to reach a public broker.

Advance only after connection success, sequence completeness, latency, downstream processing and cost meet your thresholds. Spread reconnections with jitter and respect connection/publish quotas. Keep the original broker available for the agreed rollback window, account for offline devices, and decommission only after explicit sign-off. Recheck each batch against the quotas in Section 1.

Troubleshooting

ProblemCheck First
Repeated reconnectsStop automatic retries and inspect the actual error. Check hostname, port, MQTT credentials, TLS/SNI, deployment status and duplicate Client IDs. Capture the relevant MQTT/TLS error and resolve the cause before resuming cutover.
Two clients keep disconnecting each otherTwo connections are using the same Client ID, often a forgotten test tab. Each new connection takes over the session (DISCONNECT reason code 0x8E, Session taken over), and the other client reconnects and takes it back. Give every client a unique Client ID and close any idle test connections.
Connected but no messagesConfirm both clients use the same broker; match topics exactly; check granted subscription QoS, ACLs and receiver readiness.
TLS succeeds but MQTT failsTLS success does not prove MQTT authentication or correct tenant selection. Verify SNI and MQTT credentials; do not use an API Secret as the password.
Retained value missingCheck that it was explicitly republished with Retain on and verified with a new subscription.
WebSocket connection failsCheck wss://, target port 8084, path /mqtt, browser trust and network policy.

Validation Summary and Production Checklist

CheckObserved Result
Source and target independent-client telemetry/commandsPassed at QoS 1 over WSS.
Target negative security checksOut-of-scope subscribe, out-of-scope publish and wrong password were all rejected with the expected MQTT 5 reason codes (see Section 5).
Retained configurationSource retained value read, copied explicitly, and replayed as retained on the target.
Numbered cutover telemetry10/10 unique sequences received by the target backend.
Rollback and final returnSource telemetry/command receipt restored; final target telemetry/command and retained value verified.
Not established by this labRaw MQTT/TLS 8883, embedded-device compatibility, persistent-session/offline delivery, Last Will, production latency and peak-load capacity.

Before production sign-off, verify every untested behavior your application depends on, including MQTT version, session expiry, disconnect/reconnect recovery, Last Will, large payloads, fan-out, downstream storage and budget.

What this test showed, and what it didn't

Using MQTTX Web over secure WebSockets, we moved a HiveMQ Cloud Serverless workload to EMQX Cloud Serverless by changing only the connection settings and access rules. EMQX enforced permissions with clear MQTT 5 reason codes. A retained configuration value had to be copied by hand, and it replayed correctly once it was. All ten numbered cutover messages arrived, and rollback worked in both directions.

What it didn't test matters just as much: raw MQTT over TLS on port 8883, embedded devices, persistent sessions and offline queues, Last Will, and production traffic levels. Test those with your own clients before you move real devices.

HiveMQ Cloud Serverless shuts down on December 31, 2026. For help planning your move or choosing between Serverless and Dedicated Flex, visit our HiveMQ Cloud migration page.

References

Talk to an Expert
Contact Us →

Article by

EMQX Cloud Team

EMQX Cloud Team

The EMQX Cloud team provides a secure, reliable, and fully managed MQTT service. The team assists IoT developers in easily launching MQTT services unburdened and unworried about infrastructure maintenance.