Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection time role reversal for CoAP-over-WS #311

Open
JoachimErnst opened this issue Jul 18, 2023 · 5 comments
Open

Connection time role reversal for CoAP-over-WS #311

JoachimErnst opened this issue Jul 18, 2023 · 5 comments

Comments

@JoachimErnst
Copy link

We would like to use CoAP over WS.
Is there a simple example availabe showing how the WS-client opens a websocket connection and then the WS-server side acts as
CoAP client and sends a CoAP request to the original client.
There are some remarks on that in the doc but it is not clear how to do it.
Best Regards
Joachim

@chrysn
Copy link
Owner

chrysn commented Jul 18, 2023

There are a few possible things to do (provided you have installed aiocoap with all extras):

  • Run the ./server.py example in one terminal. Then, in a different terminal, run aiocoap-client coap+ws://localhost:8683/.well-known/core -- it's really just another protocol (like coap+tcp), and the server listens to all by default, with the one documented exception of not listening on port 80 because that's privileged.
  • I'm running some public services around https://coap.amsuess.com/, all of which are also accessible via coap+ws. For example, try coap+ws://demo.coap.amsuess.com/.well-known/core or coap+ws://rd.coap.amsuess.com/.well-known/core.
  • The verdigris demo at https://chrysn.gitlab.io/verdigris/ runs in the browser, and uses coap+ws as intended. When you go to the Color Server tab, you can discover the color resources at coap+ws://rd.coap.amsuess.com/resource-lookup/ from aiocoap (or open the Color Client in another tab to switch the first tab's thumbnail color).

@JoachimErnst
Copy link
Author

JoachimErnst commented Jul 18, 2023 via email

@chrysn
Copy link
Owner

chrysn commented Jul 18, 2023

This is a rather exotic application (and thus not suitable for the server.py minimal example), but there is an example in aiocoap.cli.rd around how proxy_active is used to store remotes, and how in apply_redirection it is fed into a proxying step.

I'm a bit curious though: In my view of the CoAP architecture, this is predominantly used in reverse proxying. How do you set up the reverse proxy if it is not a resource directory (whose implementation is the example I gave)?

@JoachimErnst
Copy link
Author

JoachimErnst commented Jul 19, 2023 via email

@chrysn
Copy link
Owner

chrysn commented Jul 19, 2023

It's fundamentally possible to assign a remote through which no request has been received, but it would need some interfaces aiocoap is currently not exposing. The How and Where will depend on general use cases

Please contact me at christian@amsuess.com to check whether we can generalize your specific use case into something that can be added and documented in aiocoap. (That address is also the general entry point for professional services around aiocoap, which should ease managing confidentiality concerns.)

@chrysn chrysn changed the title Is there an example of CoAP over WS? Connection time role reversal for CoAP-over-WS Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants