What steps will reproduce the problem?
1. Start from the CoapSampleResourceServer.java and BasicCoapClient.java
examples given with this package
2. Modify the request in BasicCoapClient.java to request an observe message
from the resource (i.e coapRequest.setObserveOption(0);
coapRequest.setUriPath("/test/light"); ). See included file for details
3. Run first the server, then the client.
What is the expected output? What do you see instead?
The expected output is:
- An updated light value received whenever the value changes on the server side
What I see is:
- A ClassCastException:
Exception in thread "Thread-0" java.lang.ClassCastException:
org.ws4d.coap.messages.CoapEmptyMessage cannot be cast to
org.ws4d.coap.interfaces.CoapRequest
at org.ws4d.coap.connection.BasicCoapClientChannel.sendMessage(BasicCoapClientChannel.java:140)
at org.ws4d.coap.connection.BasicCoapClientChannel.handleMessage(BasicCoapClientChannel.java:74)
at org.ws4d.coap.connection.BasicCoapSocketHandler$WorkerThread.handleIncommingMessage(BasicCoapSocketHandler.java:272)
at org.ws4d.coap.connection.BasicCoapSocketHandler$WorkerThread.run(BasicCoapSocketHandler.java:155)
What version of the product are you using? On what operating system?
Coap source checkout:
Commit: 020caefedb4c135829f550c803deebceb29f740f [020caef]
Parents: 789c5c0959
Author: Christian <christian.lerche@uni-rostock.de>
Date: Tuesday, 12 June, 2012 11:06:01
Labels: HEAD, origin/master, origin/HEAD, master
OS: Windows 8.1 Enterprise
Please provide any additional information below.
The bug can be fixed by adding a check for CoapRequest format, i.e in
BasicCoapClientChannel.java change the sendMessage function:
@Override
public void sendMessage(CoapMessage msg) {
super.sendMessage(msg);
//TODO: check
if(msg instanceof CoapRequest){
lastRequest = (CoapRequest) msg;
}
}
I suppose this is why the "//TODO: check" was here
Original issue reported on code.google.com by luc.z...@gmail.com on 26 May 2015 at 8:08
Original issue reported on code.google.com by
luc.z...@gmail.com
on 26 May 2015 at 8:08Attachments: