question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Direct Method in module bug - preview11

See original GitHub issue

I have taken the fresh Preview11 for a spin with python 3.5.3. There is no sample code to demonstrate a module client running in an edge environment that can receive a direct method call, so here is my test-code:

from datetime import datetime
from multiprocessing.connection import Client

import os, uuid, sys, asyncio, threading
from azure.iot.device.aio import IoTHubDeviceClient, IoTHubModuleClient
from azure.iot.device import Message, MethodResponse

import os, getpass

import imutils
import json
import socket
import time
import sys

import logging
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)

async def snapmain():
    logging.debug("Setup message receiver starting")

    module_client = IoTHubModuleClient.create_from_edge_environment()

    # connect the client.
    await module_client.connect()

    # define behavior for receiving an input message on input7
    async def input1_listener(module_client):
        while True:
            input_message = await module_client.receive_message_on_input("input7")  # blocking call
            logging.debug("the data in the message received on input7 was ")
            logging.debug(input_message.data)
            logging.debug("custom properties are")
            logging.debug(input_message.custom_properties)

    # Schedule tasks for Method Listener
    listeners = asyncio.gather(
        input1_listener(module_client)
    )


def main():
    try:
        # Basic configuration: configure the root logger, including 'azure.storage'
        logging.basicConfig(format='%(asctime)s %(name)-20s %(levelname)-5s %(message)s', level=logging.DEBUG)

        # If using Python 3.6 or below, use the following code instead of asyncio.run(snapmain()):
        loop = asyncio.get_event_loop()
        loop.create_task(snapmain())
        loop.run_forever()

    except KeyboardInterrupt:
        pass


if __name__ == "__main__":
    main()

The errors keeps coming like this:

azure.iot.device.common.transport_exceptions.ConnectionDroppedError: None
INFO:Connection State - Disconnected
INFO:Cleared all pending method requests due to disconnect
DEBUG:Sending CONNECT (u1, p1, wr0, wq0, wf0, c0, k60) client_id=b'Haven2/motion-detection'
DEBUG:Received CONNACK (1, 0)
INFO:connected with result code: 0
DEBUG:Starting _on_mqtt_connected in pipeline thread
INFO:_on_mqtt_connected called
DEBUG:PipelineRootStage: on_connected.  on_connected_handler=<function IoTHubPipeline.__init__.<locals>._on_connected at 0xb63f5ae0>
DEBUG:Starting _on_connected in callback thread
WARNING:Connection was unexpected
INFO:Connection State - Connected
INFO:disconnected with result code: 1
DEBUG:Starting _on_mqtt_disconnected in pipeline thread
ERROR:MQTTTransportStage: _on_mqtt_disconnect called: Out of memory.
DEBUG:PipelineRootStage: on_disconnected.  on_disconnected_handler=<function IoTHubPipeline.__init__.<locals>._on_disconnected at 0xb63f5b28>
DEBUG:Starting _on_disconnected in callback thread
WARNING:MQTTTransportStage: disconnection was unexpected
ERROR:Exception caught in background thread.  Unable to handle.
azure.iot.device.common.transport_exceptions.ProtocolClientError: Out of memory.

The above exception was the direct cause of the following exception:

azure.iot.device.common.transport_exceptions.ConnectionDroppedError: None
INFO:Connection State - Disconnected
INFO:Cleared all pending method requests due to disconnect

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
cartertinneycommented, Sep 25, 2019

Thanks for the detailed log and sample. We’ll start looking into this. To be clear, this is related to receiving input messages, not direct method requests, correct? I don’t see any reference to .receive_method_request() in your sample.

0reactions
az-iot-builder-01commented, Dec 25, 2019

@njbuch, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey

Read more comments on GitHub >

github_iconTop Results From Across the Web

Edge Module Direct Method setup - Microsoft Q&A
We are getting an error at our custom edge module when trying to setup Directmethod. We followed the article followed in
Read more >
Changelog | Burst | 1.7.4 - Unity - Manual
Fixed a bug where the Burst post-processing for direct call would cause duplicate function pointers to be compiled, wasting compile time in the ......
Read more >
Class GeometryUtils | Unity Reflect | 1.0.0-preview.11
This function finds those two times. The same logic applies to line segments, where the one point is the starting position, and the...
Read more >
Positioning Module Software Package Operating Manual
1.3 Additions/Modifications Function according to SW0D5C-QD75P-E Versions. ... network remote I/O module , a direct connection cable to the QD75 on the main ......
Read more >
azure-iothub - UNPKG
21, * Invoke Cloud to Device Direct Methods on a device ... function(err, deviceInfo, res) {. 42, if (err) console.log(op + ' error:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found