okleine / nCoAP

Java implementation of the CoAP protocol using netty
BSD 3-Clause "New" or "Revised" License
179 stars 57 forks source link

Fixing SimpleCoapServer + SimpleCoapClient -- step I #37

Closed boldt closed 7 years ago

boldt commented 7 years ago

The current simple-client cannot be used to communitcate to the simple-server, since some block-wise transfer which communicated to vs0.inf.ethz.ch is included in the example.

Thus, I tried to get the simple-server and simple-client running again. I created some small fixes (see this PR). I am building the project (with my fixes) as follows:

mvn package -DskipTests

Then I am running the two example applications in two terminals:

java -jar ncoap-simple-server/target/ncoap-simple-server-1.8.3-SNAPSHOT.one-jar.jar 
java -jar ncoap-simple-client/target/ncoap-simple-client-1.8.3-SNAPSHOT.one-jar.jar --host localhost --port 5683 --path /utc-time --observing --maxUpdates 100

The client gets one log Payload: The current time is 11:30:27, followed by Blockwise response transfer failed! for each notification.

What do I have to change in the (fixed) client/server to get the examples work again?

okleine commented 7 years ago

Indeed, there were some issues but with commit af3be2890ed0c60c2b39ca50dbbe824f21a997ab those should be fixed. Please try!

boldt commented 7 years ago

It still has an issue. After the 15th response the client shuts down. I'm running (as above):

mvn package -DskipTests
java -jar ncoap-simple-server/target/ncoap-simple-server-1.8.3-SNAPSHOT.one-jar.jar 
java -jar ncoap-simple-client/target/ncoap-simple-client-1.8.3-SNAPSHOT.one-jar.jar --host localhost --port 5683 --path /utc-time --observing --maxUpdates 100

The corresponding log:

[...]
2017-03-29 11:03:23,556 | nCoAP Client I/O Worker #6       | SimpleObservationCallback           | INFO  | Received #15: [Header: (V) 1, (T) CON (0), (TKL) 8, (C) CONTENT (69), (ID) 14744 | (Token) 0xF5CE5CE8C5CCAE52 | Options: (No. 4) 0x0000015B194E259C (No. 6) 5121438 (No. 12) 0 (No. 14) 4 | Content: The current time is ... ( 28 bytes)]
2017-03-29 11:03:23,557 | nCoAP Client I/O Worker #6       | SimpleObservationCallback           | INFO  | Full Payload:
The current time is 09:03:23
2017-03-29 11:03:23,558 | nCoAP Client I/O Worker #6       | SimpleObservationCallback           | INFO  | Received 15/100 responses (continue observation: true)

2017-03-29 11:03:27,957 | main                             | CoapClient                          | WARN  | Start to shutdown nCoAP Client (Port : 53006)
2017-03-29 11:03:27,964 | main                             | CoapClient                          | WARN  | Channel closed (nCoAP Client).
2017-03-29 11:03:27,971 | main                             | CoapClient                          | WARN  | External resources released (nCoAP Client).
2017-03-29 11:03:27,971 | main                             | CoapClient                          | WARN  | Shutdown of nCoAP Client completed.
okleine commented 7 years ago

That is because the parameter --duration has a default paramter of 60, i.e. the client shuts down after 60 seconds independently of the number of responses received so far.

EDIT: I just updated the documentation (README and JavaDoc) to make this more clear (see 32d8d4460525c72fceafba6687a74e44af071c79 and 2f1c3851fa61968ae10b756733eaeb40224ad212).