Тёмный

How to create MQTT Client using .Net Core 

Daily Code
Подписаться 696
Просмотров 29 тыс.
50% 1

In this video we learn how to create .Net Core MQTT Client, we create two clients, one acts as a publisher and the other one acts as subscriber, both the clients use MQTTNet Library in order to connect to the MQTT Broker.
We Connect to publicly hosted Mosquitto Broker which is hosted at test.mosquitto.org.

Опубликовано:

 

16 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 36   
@Bloome_BlueFolf
@Bloome_BlueFolf Год назад
Simple, short and clear.
@luit.s
@luit.s 2 года назад
Thanks, this is exacly what I was looking!!!!!!
@RishabhSharma_95822
@RishabhSharma_95822 2 года назад
Glad I could help!
@prof_as
@prof_as 27 дней назад
flawless 🔥🔥🔥
@GarryWhitworth
@GarryWhitworth 2 года назад
Thank you Rishabh. That was a good tutorial to follow. Now to see if I can make it wotk with the MQTT server on TTN...
@RishabhSharma_95822
@RishabhSharma_95822 2 года назад
Glad it was helpful Garry!
@fooballers7883
@fooballers7883 15 дней назад
Nice work....thank you.
@CaptainBiceps
@CaptainBiceps 2 года назад
Thanks a lot. But it look like handler functions doesn't exist anymore on MqttNet 4.0.0.*
@lucasdeo.baptista8787
@lucasdeo.baptista8787 2 года назад
Very good, it helps me a lot, thank you
@RishabhSharma_95822
@RishabhSharma_95822 2 года назад
Glad it helped!
@EnisHrnjic
@EnisHrnjic 2 года назад
simple and concise instructions, tnx u very much. the use of TopicFilterBuilder is obsolete now.
@toetoeag
@toetoeag 2 года назад
Thanks a lot for sharing. It's working :)
@RishabhSharma_95822
@RishabhSharma_95822 2 года назад
Glad it was helpful! 😁
@АндрейЛысов-б9ъ
Greate!
@audiofrank6747
@audiofrank6747 2 года назад
Awesome!
@RishabhSharma_95822
@RishabhSharma_95822 2 года назад
Thanks!
@valkokk
@valkokk 2 года назад
Can you do one new example, using v4 of MQTTNet, but with continuous write/publish and continuous read/consume? Winforms? Tks.
@pranavkadlag9691
@pranavkadlag9691 2 года назад
Which Workload we have to choose for MQTT Packages
@harshithal1404
@harshithal1404 2 года назад
I followed everything you taught in this video but getting an error as " Program doesn't contain static "Main" method suitable for an entry point" Please help!!
@RishabhSharma_95822
@RishabhSharma_95822 2 года назад
Check if you have a main method which is the entry point for your application, it is the main which creates the instance of other class and calls the methods using those instances like subscribe and receive messages.
@skkingcse
@skkingcse 2 года назад
Thanks for the video , its really help me alot, One issue i am facing while connecting broker getting timeout message,unable to connect broker. Can you please help on this
@RishabhSharma_95822
@RishabhSharma_95822 2 года назад
The public broker (test.mosquitto.org) is open to entire world so its pretty busy, maybe that is the reason you getting timeout, try to host your own broker locally and connect to it, let me know if you are still facing an issue then in that case there is probably an issue with code.
@parthi2929
@parthi2929 Год назад
Please show how to do the same in webapp (webapi).
@zorzional
@zorzional 2 года назад
Hello. If I would know which topic is received how could I do that?
@RishabhSharma_95822
@RishabhSharma_95822 2 года назад
can you please elaborate, I couldn't understand your query.
@zorzional
@zorzional 2 года назад
I want to show a message in a textbox according to type of topic. How can I know which topic is received?
@RishabhSharma_95822
@RishabhSharma_95822 2 года назад
You should not check for the topic in case of every received message, it is the other way round, you have to subscribe to the topics in which you are interested in, the broker will take the responsibility of sending you all the messages for the topic which you have subscribed to, in case you are subscribing to multiple topics you need to also specify multiple message handlers in case you are planning to execute different functionality per topic.
@zorzional
@zorzional 2 года назад
@@RishabhSharma_95822 Can you give an example how to subscribe to multiple topics and use multiple message handlers? Thanks.
@the0nerens
@the0nerens 2 года назад
Nice video, really helped out a lot! one quick question tho, how does it work with authentication? (my university has a broker running but it requires authentication) i guess i have to add something like a username and a password to my OptionsBuilder?
@RishabhSharma_95822
@RishabhSharma_95822 2 года назад
Yes exactly, once the broker is configured with a given username and password, in c# client you need to add .WithCredential(username, password) in your OptionsBuilder
@jesperkped
@jesperkped 2 года назад
Please audio normalize your videos before uploading. it vary wildly with other videos on youtube and it makes it not very enjoyable having to turn volume up and down all the time.
@justinteh1262
@justinteh1262 2 года назад
Hey there, thanks for the tutorial! Was just wondering how you could solve an issue on Async connection at both Publisher & Subscriber side for "await mqttClient.ConnectAsync(mqttClientOptions, CancellationToken.None);" 'MQTTnet.Exceptions.MqttCommunicationTimedOutException' in System.Private.CoreLib.dll
@RishabhSharma_95822
@RishabhSharma_95822 2 года назад
ConnectionTimedOut mostly is due to the client not being able to establishing a connection with broker, the sequence does not matter much either the publisher or subscriber can establish the connection first in an asynchronous manner.
@justinteh1262
@justinteh1262 2 года назад
@@RishabhSharma_95822 Ah I see... is there any way/MQTT setting we can implement to ensure the connection can be established properly to the MQTT broker? As some Wi-Fi seems to block the connection (presumably due to Firewall, etc)?
@RishabhSharma_95822
@RishabhSharma_95822 2 года назад
if the connection is not established it'll automatically timeout and the event handler for successful connection will never be triggered, hence you'll get to know at the time of connection itself incase there is some issue.
Далее