sane-city / wot-servient

W3C Web of Things implementation for Java
MIT License
30 stars 5 forks source link

Link-local addresses don't work #9

Closed Citrullin closed 3 years ago

Citrullin commented 3 years ago

I wrote a simple boilerplate project in scala. The CoAP server is a RIOT process in Linux. An explanation how to run it can be found here. Instead of the branch wot_plugfest_09_2020 use wot_gcoap. Another more simple server probably also does the job. The CoAP server is accessible. I tested this with the coap-client in libcoap.

./coap-client -m get coap://[fe80::8029:2fff:fe69:6cc5%tapbr0]/.well-known/wot-thing-description
{"@context":["https://www.w3.org/2019/wot/td/v1",{"cov":"http://www.example.org/coap-binding#"},{"saref":"https://w3id.org/saref#"}],"securityDefinitions":{"basic_schema":{"scheme":"basic","descriptions":{"en":"Basic sec schema"},"description":"Basic sec schema","in":"query","name":"querykey"}},"security":["basic_schema"],"@type":["saref:LightSwitch"],"titles":{"en":"English title","de":"Deutscher Titel"},"title":"English title","descriptions":{"en":"English description","de":"Deutsche Beschreibung"},"description":"English description","properties":{"echo":{"observable":false,"forms":[{"op":["readproperty"],"href":"/echo","contentType":"text/plain","cov:methodName":"GET"}]}}}

When I don't catch the exception, I get the following exception:

java.util.concurrent.ExecutionException: city.sane.wot.binding.ProtocolClientException: request timeouts or has been rejected by the server

I also ran it with a link-local address for the server, defined in the application.conf

    coap {
        addresses = [
            "fe80::8029:2fff:fe69:6cc4"
        ]
    }

I checked the tapbr0 interface with Wireshark. There is, in both cases, no traffic at all. I guess the zone Id in the IPv6 gets ignored. I haven't checked, if this is just a parsing error, or if the underlying client is responsible for this error.

HeikoBornholdt commented 3 years ago

I'm curious if this problem is caused by my code or the library used for CoAP (https://mvnrepository.com/artifact/org.eclipse.californium/californium-core/1.0.7).

I have extracted the underlying library coap calls. Can you please check if the error occurs here as well?

import org.eclipse.californium.core.CoapClient;
import org.eclipse.californium.core.CoapHandler;
import org.eclipse.californium.core.CoapResponse;
import org.eclipse.californium.core.coap.CoAP;
import org.eclipse.californium.core.coap.Request;

import java.net.URI;
import java.net.URISyntaxException;

public class CoapDebugTest {
    public static void main(String[] args) throws URISyntaxException {
        CoapClient client = new CoapClient(new URI("coap://[fe80::9c7c:12ff:fe70:8f55%tapbr0]/.well-known/wot-thing-description")).setTimeout(10 * 1000L);
        Request request = new Request(CoAP.Code.GET);
        client.advanced(new CoapHandler() {
            @Override
            public void onLoad(CoapResponse coapResponse) {
                System.out.println("CoapDebugTest.onLoad");
                System.out.println("coapResponse = " + coapResponse);
            }

            @Override
            public void onError() {
                System.out.println("CoapDebugTest.onError");
            }
        }, request);
    }
}
Citrullin commented 3 years ago

@heikobornholdt I had to remove the @Override because it is an interface and overrides nothing. I get a CoapDebugTest.onError in the terminal. In Wireshark I see Neighbor Neighbor Solicitations.

75  77.357915417    fe80::8029:2fff:fe69:6cc4   ff02::1:ff70:8f55   ICMPv6  86  Neighbor Solicitation for fe80::9c7c:12ff:fe70:8f55 from 82:29:2f:69:6c:c4
HeikoBornholdt commented 3 years ago

What version of wot-servient did you use? I have created an Ubuntu VM with RIOT server, and I cannot reproduce the error with the current SNAPSHOT version.

Citrullin commented 3 years ago

What version of wot-servient did you use? I have created an Ubuntu VM with RIOT server, and I cannot reproduce the error with the current SNAPSHOT version.

You are right. Happens on 1.13, but not on 1.15-SNAPSHOT. So, I close it :)