# Connect MQTT broker with pre-signed url

**URL:** <https://community.hivemq.com/t/connect-mqtt-broker-with-pre-signed-url/751>\
**Category:** HiveMQ Client Library\
**Created:** [October 4, 2021, 5:16pm UTC](https://community.hivemq.com/t/connect-mqtt-broker-with-pre-signed-url/751 "2021-10-04T17:16:21Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Daria\_H](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Daria\_H](https://community.hivemq.com/u/Daria_H)\
**Post date:** [February 21, 2022, 12:51pm UTC](https://community.hivemq.com/t/connect-mqtt-broker-with-pre-signed-url/751/8 "2022-02-21T12:51:17Z")

</div>

Hi mestre,

Are you already [signed up for a free hivemq cloud](https://cloud.hivemq.com) account? Once you are signed, to go your cluster and click Manage Cluster → Getting started. In the list of sample client find one that says Java(Websocket) hivemq-mqtt-client:  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/hivemq1/original/1X/eda82dce35aa397c244bcd152a637ecad994f0c4.png)

There you will find an example of Websocket Client: [https://console.hivemq.cloud/clients/websocket-java](https://console.hivemq.cloud/clients/websocket-java)

Take a look at the code that is building the client:

```auto
final Mqtt5BlockingClient client = MqttClient.builder()
                .useMqttVersion5()
                .serverHost(host)
                .serverPort(8884)
                .sslWithDefaultConfig()
                .webSocketConfig()
                .serverPath("mqtt")
                .applyWebSocketConfig()
                .buildBlocking();

```

Note a few things:

- `subprotocol` is not explicitly updated, it is, by default, “mqtt”;
- `serverPath` is “mqtt” (like in your last attempt);
- there is a call to `.applyWebSocketConfig()` before `.buildBlocking();`

Please try to change your code this way and let us know the result. For the `queryString` use the part of the string that follows the “?”: “protocol://host:port/mqtt?xxx-xxx-xxx-xxx-xxx-x…”

Thanks,  
Dasha from HiveMQ Team

---

_[View the full topic](https://community.hivemq.com/t/connect-mqtt-broker-with-pre-signed-url/751)._
