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

How is it possible to send messages from server to client? #23

Closed
thosaa opened this issue Oct 3, 2018 · 1 comment
Closed

How is it possible to send messages from server to client? #23

thosaa opened this issue Oct 3, 2018 · 1 comment

Comments

@thosaa
Copy link

thosaa commented Oct 3, 2018

Hi

I was looking into this project as it has support for TCP as written in the README file.
I have connected a client to a server and can send messages and receive answers.

In order to make two-way communication between client and server when the client is behind a NAT or firewall without using (the currently unsupported) websockets, I was looking into sending a message from the server to the client by using the already established session, which should be possible as written in the RFC8323 section 3.3 'Message Transmission':

The Transport Connection is bidirectional, so requests can be sent by
both the entity that established the connection (Connection
Initiator) and the remote host (Connection Acceptor).

I can see that there is a makeRequest() method for the server, but I am missing a corresponding addRequestHandler for the client in order to catch the request made by the server.

Is this functionality supported at the moment?
Or am I missing something obvious?

Thanks

@szysas
Copy link
Contributor

szysas commented Oct 3, 2018

Hi,

Can you provide your code snippet?
I guess your are using CoapClient class, note that it is just a helper adapter over CoapServer class.
What you can do on client side is to first to initialise CoapServer class. Then, if needed, create CoapClient object from it:

    CoapClient client = CoapClientBuilder.clientFor(serverAddress, cnn);

For example: https://github.com/ARMmbed/java-coap/blob/master/coap-core/src/test/java/protocolTests/ClientServerTest.java#L254

@szysas szysas closed this as completed Dec 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants