Giter VIP home page Giter VIP logo

Comments (5)

jdamme avatar jdamme commented on August 9, 2024

I tried this from what i found online but still got the same problem.

import logging
import asyncio
import struct
from aiocoap import *

logging.basicConfig(level=logging.INFO)

node_id = "1"
control_prefix = "fd00:c:"
node_interface_address = "::2"
NodeControlAddress = control_prefix + node_id + node_interface_address

@asyncio.coroutine
def main():
    protocol = yield from Context.create_client_context()

    payload = bytearray()
    payload.append(0)  # connector id
    payload.append(1)  # function id
    payload.append(1)  # num_of_args
    payload.extend(struct.pack("<H", 1000))

    print(repr((payload)))

    request = Message(code=POST, payload=payload, uri='coap://['+NodeControlAddress+']/wishful_funcs')

    try:
        response = yield from protocol.request(request).response
    except Exception as e:
        print('Failed to fetch resource:')
        print(e)
    else:
        print('Result: %s\n%r' % (response.code, response.payload))

    protocol.shutdown()

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
    print(asyncio.Task.all_tasks(loop=loop))
    loop.close()

from aiocoap.

chrysn avatar chrysn commented on August 9, 2024

hello @jdamme, please retry with the latest master; some bugs have slipped into beginning of this week's master that are now fixed (and are waiting for better unit tests -- see #50 -- for this not to happen again).

from aiocoap.

jdamme avatar jdamme commented on August 9, 2024

Still have the same issue with the updated master code.

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    print('Running main')
    try:
        loop.run_until_complete(main())
    except Exception:
        print(e)
    print('Tasks:')
    print(asyncio.Task.all_tasks(loop=loop))
    print('Closing loop')
    loop.close()

gives this output:

user@instant-contiki:/git/coap_control$ python3.4 get3.py
Running main
bytearray(b'\x00\x01\x01\xe8\x03')
Result: 2.05 Content
b'\x00\x01\x00\x01\x00'
Shutdown protocol
Tasks:
set()
Closing loop
Exception ignored in: user@instant-contiki:/git/coap_control$

from aiocoap.

chrysn avatar chrysn commented on August 9, 2024

Sorry, I could still not reproduce this. Can you provide a (simple, maybe aiocoap) mock for the server's behavior?

from aiocoap.

chrysn avatar chrysn commented on August 9, 2024

Closing this as unreproducible, please feel free to reopen if you can help find a way that others can experiment with the error.

from aiocoap.

Related Issues (20)

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.