---
title: "Discussion on \"Basic MQTT broker with C#\" | Hashnode"
description: "Discussion on \"Basic MQTT broker with C#\". A Simple MQTT broker with c#"
url: "https://hashnode.com/posts/basic-mqtt-broker-with-c-sharp/61eb28425fbc177f9f3b3595"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Basic MQTT broker with C#](https://blog.behroozbc.ir/basic-mqtt-broker-with-c-sharp?utm_source=hashnode&utm_medium=feed)

A Simple MQTT broker with c#

Jan 21, 2022 · 3 min read · blog.behroozbc.ir  
Updated Jul 16, 2022  
Read the article

-   [#iot](https://hashnode.com/tag/iot)
-   [#csharp](https://hashnode.com/tag/csharp)
-   [#dotnet](https://hashnode.com/tag/dotnet)
-   [#internet-of-things](https://hashnode.com/tag/internet-of-things)

## Written by

[behrooz bozorgchamy](https://hashnode.com/@behroozbc)

@behroozbc

  
[View profile](https://hashnode.com/@behroozbc)

Student At FAU

## Responses 1

Markdown supported · ⌘↵ to post

[Jaime Stuardo](https://hashnode.com/@desytec)

[Feb 1, 2025](https://hashnode.com/posts/basic-mqtt-broker-with-c-sharp/61eb28425fbc177f9f3b3595/comment/679e6f900f45826001e352c3)

Hello... I ran this basic sample, but, how can I connect to it? I am using MQTTX client while I am running the broker locally (run by mean of Visual Studio).

I am not able to connect from the client. I tried with mqtt://localhost, mqtts://localhost, ws://localhost and wss://localhost. Nothing works.

[Bigberm](https://hashnode.com/@bigberm)

[Jul 16, 2022](https://hashnode.com/posts/basic-mqtt-broker-with-c-sharp/61eb28425fbc177f9f3b3595/comment/62d230752f551b044bc1633b)

Hi,

Sorry I want to know about this solution. 1) How to set username/password for c# MQTT Broker? 2) How to set retaining lastest published message on Broker from client's published message?

Thank you, Bigberm

[behrooz bozorgchamy](https://hashnode.com/@behroozbc)

[Jul 16, 2022](https://hashnode.com/posts/basic-mqtt-broker-with-c-sharp/61eb28425fbc177f9f3b3595/comment/62d230752f551b044bc1633b#reply-62d256de2f551b044bc16833)

Hi,

1) I am writing an article about it.

2) you can publish message with `MqttApplicationMessage` like

```
var message = new MqttApplicationMessage()
    {
        Topic = "",
        Payload = Encoding.UTF8.GetBytes("gg"),
        Retain = true
    };
```

[Bigberm](https://hashnode.com/@bigberm)

[Jul 17, 2022](https://hashnode.com/posts/basic-mqtt-broker-with-c-sharp/61eb28425fbc177f9f3b3595/comment/62d230752f551b044bc1633b#reply-62d394d1e52a5d129a0c1fcc)

[behrooz bozorg chami](https://hashnode.com/@behroozbc)

> 1) I am writing an article about it. Thank you and waiting for this article topic "How to set username/password for c# MQTT Broker".
