Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

CoAP port 5683 conflicts with same used by iot-rest-api-server #9

Closed
mmccool opened this issue Oct 29, 2017 · 2 comments
Closed

CoAP port 5683 conflicts with same used by iot-rest-api-server #9

mmccool opened this issue Oct 29, 2017 · 2 comments

Comments

@mmccool
Copy link

mmccool commented Oct 29, 2017

The IoT REST API Server, used by OCF to convert OCF resources from CoAP to HTTP, also wants to bind port 5683 for CoAP services. Trying to start the thing directory on the same computer an iot-rest-api-server is also running causes an error when the thing directory tries to bind the same port. This is non-fatal (the http server still comes up) but is problematic, especially if both the thing directory and the iot-rest-api-server are started automatically (in which case there would be a race condition on who can grab the port first...).

As a workaround, the COAP_PORT property in Californium.properties can be changed to avoid a conflict (I changed mine to 5684).

COAP_PORT=5684

[EDIT: See below, this a poor choice, as it conflicts with COAPS. 15683 is what I am trying to use now.]

Of course this may cause issues with devices looking for CoAP resource directories in a certain place... to discuss.

As a related issue, gateways are often (should be) running firewalls. You may have to explictly open the relevant ports to make the thing directory service available locally to other devices. I used the following, (similar to what is described in the iot-rest-api-server documentation) to open my (re-defined) CoAP port:

sudo iptables -A INPUT -p udp --dport 5684 -j ACCEPT

The default HTTP ports don't conflict since iot-rest-api-server uses 8000 by default (for HTTPS too) and the thing directory uses 8080.

@mmccool
Copy link
Author

mmccool commented Oct 29, 2017

A couple of issues...

  • 5683 is a poor choice for an alternative port, since it is the port used by CoAPS. Instead I am using 15683 (and likewise, 15684 might be reasonable for COAPS).

  • Changing COAP_PORT in the Californium.properties file does not seem to have any effect. Poking around in the source code however I found the following in ThingDirectory.java, so changing the coap port with the -c option (and the http port with -h) seems to be supported:

      // Default values
      int portCoAP = 5683;
      int portHTTP = 8080;
      ...
      options.addOption("c", true, "CoAP port number. Default is 5683.");
      options.addOption("h", true, "HTTP port number. Default is 8080.");
    

@vcharpenay
Copy link
Collaborator

Indeed. Run ./thingweb-directory -c XXXX to start the CoAP server on port XXXX.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants