mwasilak / txThings

CoAP library for Twisted
94 stars 43 forks source link

Sending Multiple Payloads one after another #14

Closed aaravind1993 closed 7 years ago

aaravind1993 commented 8 years ago

Hello I am a student at USC. I am trying to do a mini project involving CoAP where my client will keep getting information from a bunch of sensors and I have to send the information to a server. I was going throug your Coap Client code and when I tried modifying it to send multiple payloads one after another I got an error saying blocks came out of order. Can you please help me out in transmitting payloads one after another? For example, say I get temperature and pressure from two sensors. These values keep changing every one minute. So every minute I have to send a new payload containing the new information to the server. The payload is in JSON format. As I said before when try to send it the blocks arrive out of order and I get an error.

mwasilak commented 8 years ago

Hello,

the error "Error: Request block received out of order!" is caused when Block1 blocks come to server in incorrect order. According to CoAP documents, server doesn't have to support receiving blocks out of order. As far as I remember incoming Block1 transfers are identified by a tuple (sender IP, resource path). Therefore possible causes of this bug:

  1. You start two blockwise transfers from the same sensor to the same resource. This is not supported by CoAP protocol. See draft-ietf-core-block-20:

    The Block1 option provides no way for a single endpoint to perform multiple concurrently proceeding block-wise request payload transfer (e.g., PUT or POST) operations to the same resource.

  2. You use a proxy or some other technique which causes the requests to come to server from the same IP address. Server sees it as the same transfer and complains about incorrect order.

Solutions:

  1. Finish previous blockwise transfer before you start another (best solution!!!).
  2. If you absolutely must use two transfers, you need to use temporary resources - this is a bit complicated: a) send GET request to some "register transfer" resource" - server returns name of temporary resource b) send PUT Block1 transfer to that temporary resource

Best Regards Maciej Wasilak

2016-06-09 13:04 GMT+02:00 aaravind1993 notifications@github.com:

Hello I am a student at USC. I am trying to do a mini project involving CoAP where my client will keep getting information from a bunch of sensors and I have to send the information to a server. I was going throug your Coap Client code and when I tried modifying it to send multiple payloads one after another I got an error saying blocks came out of order. Can you please help me out in transmitting payloads one after another? For example, say I get temperature and pressure from two sensors. These values keep changing every one minute. So every minute I have to send a new payload containing the new information to the server. The payload is in JSON format. As I said before when try to send it the blocks arrive out of order and I get an error.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mwasilak/txThings/issues/14, or mute the thread https://github.com/notifications/unsubscribe/AAme_bRBRB9T4ec1wu6nhXGXa9wrNraNks5qJ_NLgaJpZM4Ix27y .