GithubHelp home page GithubHelp logo

caseonline.azure.webjobs.extensions.mqtt's People

Contributors

carlossardo avatar dependabot-preview[bot] avatar expecho avatar keesschollaart81 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

caseonline.azure.webjobs.extensions.mqtt's Issues

Version conflicts

I tried following the instruction but end up with a lot of versioning conflicts, such as for Newtonsoft.Json. Could you maybe update the readme with sample PackageReferences?

MqttCommunicationClosedGracefullyException thrown when connecting via TLS

After configuring the broker with certificates and also using the MqttClientOptionsBuilderTlsParameters when setting up the connection to the broker from the Azure Function trigger, we immediately get the MqttCommunicationClosedGracefullyException after deploying the Function to the Azure resource.

This issue exists solely when running on Azure, for local debugging of the Function, it works just fine.

Are there any ideas as to why this happens?

Access to Application Settings in MQTT Topic definition

Hi,

according to this document on Azure Functions Binding Syntax it should be possible to access the Application Settings of a Functions App by using the %AppSetting% syntax in the definition of a binding. Unfortunately this doesn't seem to work in my code which is implemented as follows:

[FunctionName("OnDeviceCreate")]
public static async Task OnDeviceCreate([MqttTrigger(typeof(TTNMqttConfigProvider), "%TTNAppID%/devices/+/events/create")] IMqttMessage message, ILogger logger)
{
    logger.LogInformation($"{DateTime.Now:g} Creation message for topic {message.Topic}");
    ....

Is there another way to access Application Settings from an MqttTrigger Binding Definition?

Thanks in advance!

Custom authentication

Hi @keesschollaart81 ,

First i would like to thank you for this implementation of MQTT in Azure Function, it really helps.

I have the fallowing scenario.
I want to connect to a MQTT broker but the password expire after a certain time and i need to updated it and restart the MQTT client.
Is there a way to implement custom authentication?

Thank you

how to subscribe mutiple-topics

[MqttTrigger(typeof(MqttConfigProvider), "TOPIC/#")]IMqttMessage message, ILogger log)

How can I subscribe several topics at same time from a message broker?
Please, describe some ways with code...

Message to one topic also triggers another function with different topic

Hi,

I have assigned two triggers for different topics to two functions as in the following code snippet:

public static class TTNAzureDeviceManagement
{
    [FunctionName("OnDeviceCreate")]
    public static async Task OnDeviceCreate([MqttTrigger(typeof(TTNMqttConfigProvider), "ttn-mapper-jsi/devices/+/events/create")] IMqttMessage message, ILogger logger)
    {
        logger.LogInformation($"{DateTime.Now:g} Creation message from topic {message.Topic}");
        ....
    }

    [FunctionName("OnDeviceDelete")]
    public static async Task OnDeviceDelete([MqttTrigger(typeof(TTNMqttConfigProvider), "ttn-mapper-jsi/devices/+/events/delete")] IMqttMessage message, ILogger logger)
    {
        logger.LogInformation($"{DateTime.Now:g} Deletion message from topic {message.Topic}");
        ....
    }
}

When I now run these function on Azure and send a message to one of the topics (e.g. devices/+/events/create) both functions are executed as can be seen in the following log:

2019-03-10T12:36:11.741 [Information] Executing 'OnDeviceCreate' (Reason='Mqtt fired at 2019-03-10T12:36:11.7416672+00:00', Id=84a4a1e1-136d-4cd6-847d-4c79fc5311c6)
2019-03-10T12:36:11.743 [Information] 3/10/2019 12:36 PM Creation message from topic ttn-mapper-jsi/devices/test/events/delete
2019-03-10T12:36:11.788 [Information] 3/10/2019 12:36 PM Added device test to IoT Hub
2019-03-10T12:36:11.788 [Information] Executed 'OnDeviceCreate' (Succeeded, Id=84a4a1e1-136d-4cd6-847d-4c79fc5311c6)

Notice that the "OnDeviceCreate" function was executed while the topic which was triggered was "devices/test/events/delete". The "OnDeviceDelete" functions is executed as well but that's in another log.

Is this a bug or am I doing something wrong here?

Thanks in advance!

Publish as azure webjob?

In order to minimize costs.. is it possible to publish this as an azure webjob instead of function? (The naming indicates something in that direction)

Unable to configure binding 'message' of type 'mqttTrigger'

Hi,
When using this extension with an Azure Function v2 or v3 in Visual Studio I get the following error message when running locally:
"The 'TestSubscriberFunction' function is in error: Unable to configure binding 'message' of type 'mqttTrigger'. This may indicate invalid function.json properties. Can't figure out which ctor to call."

The function seems to work anyway because I do get data from the MQTT Broker I connect to but I am not sure if this error message is causing something else to not work within the Function framework.

Azure function app hang as MQTTnet.Exceptions.MqttCommunicationException, MQTTnet.Exceptions.MqttCommunicationTimedOutException

If there is exceptions regarding to connection then the azure function app will be hung.

These are exceptions:

  • ‘MQTTnet.Exceptions.MqttCommunicationException : No connection could be made because the target machine actively refused it. [::ffff:13.69.85.206]:1883’ at 2020-12-22 15:26:21.4423821 UTC
  • ‘MQTTnet.Exceptions.MqttCommunicationTimedOutException : Exception of type 'MQTTnet.Exceptions.MqttCommunicationTimedOutException' was thrown.’ at 2020-12-29 15:25:50.7264167 UTC

This is the information from MS support.
“Our current speculation is that, when the function was running, the target server refused the connection for some reason which caused the function code stuck in deadlock. This also leads to the function process hanging the whole time.”

Is there anyone meet this issue?

Reuse connection string

Hey,
I understand that each Function needs it's own connection to the MQTT-broker. But is there a way to reuse the same connection string?

I have a need for at least three functions subscribing to the same MQTT-broker, listening for different topics. It seems redundant to have to declare three identical connection strings just to make them understand that they need a new connection...

[FunctionName("TestReceiver")]
public static void TestReceiver([MqttTrigger("test/#")]IMqttMessage message, ILogger log)
{
    log.LogInformation("TestReceiver function triggered!");

    var body = message.GetMessage();
    var bodyString = Encoding.UTF8.GetString(body);
    log.LogInformation($"TestReceiver, topic {message.Topic}: {bodyString}");
}


[FunctionName("TestDeviceReceiver")]
public static void TestDeviceReceiver([MqttTrigger("device/#")] IMqttMessage message, ILogger log)
{
    log.LogInformation("TestDeviceReceiver function triggered!");

    var body = message.GetMessage();
    var bodyString = Encoding.UTF8.GetString(body);
    log.LogInformation($"TestDeviceReceiver, topic {message.Topic}: {bodyString}");
}

Maybe username/password configuration does not work?

Hello. I am trying to write an Azure Function which subscribes to some topics on a MQTT broker, but I am not able to complete the authentication...

I mean: I am using a connection string like:

"MqttConnection": "Server=my.server.com;Username=12345;Password=mypassword"

but if I attach the debugger to the MQTT broker (based on MQTTnet) is see that both username and password in the MqttServer's authentication validator are always null (and so the MQTT broker validator implementation refuses the connection).

Am I forgetting something?

If I modify the broker implementation for accepting any username/password (even null) then everything else works perfectly fine... so I am close to the success, but still missing the authentication part... can anybody help? Thanks.

Frequent disconnect issue

I am not sure why disconnect between my broker and function app which delivery telemetry message to table storage in Azure. The connection is working very well during several hours, but after then disconnected them and not reconnected again.

Why is that happening? Could you give me some comments to fix?

Below is my code.

public static void Run(  [MqttTrigger(typeof(MqttConfigProvider), "TOPIC/#1", "TOPIC/#2", TOPIC/#3", "TOPIC/#4")]IMqttMessage message,  ILogger log)
{
  ....
}

public class MqttConfigProvider : ICreateMqttConfig
{
     public CustomMqttConfig Create(INameResolver nameResolver, ILogger logger)
     {
            var connectionString = new MqttConnectionString(nameResolver.Resolve("MqttConnection"), "CustomConfiguration");

            var options = new ManagedMqttClientOptionsBuilder()
                     .WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
                     .WithClientOptions(new MqttClientOptionsBuilder()
                     .WithClientId(connectionString.ClientId.ToString())
                     .WithTcpServer(connectionString.Server, connectionString.Port)
                    .WithCleanSession()
                    .Build())
              .Build();

            return new MqttConfigExample("CustomConnection", options);
      }
 }

 public class MqttConfigExample : CustomMqttConfig
{
    public override IManagedMqttClientOptions Options { get; }
    public override string Name { get; }
    public MqttConfigExample(string name, IManagedMqttClientOptions options)
    {
         Options = options;
          Name = name;
     }
 }

SNAT Port Exhaustion issue

Hey,
We meet the SNAT Port Exhaustion issue on Azure Function when using this Lib. Does anyone know about this SNAT issue and how to solve it?
I am appreciated any help.

Input from one MQTT connection, output to another MQTT connection

Hi, the library is great and it's something It really fits to my needs right now. I was just curious if it's possible to set one connection for input and another one for output? My use case is to subscribe to one and to publish filtered messages to another broker.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.