Open MainReturnZero opened 7 years ago
Hi, sorry but I don't understand which source file has the bug on line 143-147...
Altough i cannot find either those lines refered, i have the same problem, and it's just what that user says. the block1 response of the last block from the server (Using californium a server) sets the M flag to 0, but the block is still there.
Looking at the code, in the blocklayer.py, receive_response method https://github.com/Tanganelli/CoAPthon/blob/18478edd869cc3de2e2e0bf82c09a1814bb90504/coapthon/layers/blocklayer.py#L122
It assumes that the block won't be there. I changed that line into, without removing the None check:
blockwise_finished = transaction.response.block1 is None or transaction.response.block1[1] == 0
if key_token in self._block1_sent and (not blockwise_finished):
And with that the blockwise transfers ends correctly
@sunbit Could you create a pull request so I will merge it into the code?
Thanks Giacomo
Line 143-147: it should be
item.m
instead ofm
. This issue will occur when using put or post transfer a large file or large payload(>1024byte). This bug is introduced at this commit: https://github.com/Tanganelli/CoAPthon/commit/3b80769f183367ed39283e20573718e55b7468df#diff-956c81d955e4d02e1bbae6100008141fYou should not rely on server will response with block1 is None to stop blockwise transfer. In the standard, it says: A Block1 Option in control usage in a response (e.g., a 2.xx response for a PUT or POST request):
So, when responding to the last block, the server should not delete Block1 field.