java, webservice, SOAP, thread and websocket - java

I have a java client calling a java SOAP webservice deployed on glassfish server 4.1, that same java client also has a websocket connection to a server deployed on the same server.
Basically my architecture is this I have a java client calling a SOAP webservice, and connected to a java websocket server endpoint. Why? You can akin this to a bank, the client calls the SOAP webservice for say to check the account balance, then the websocket serves in notifying the client when a credit/debit has been made on the account.
Problem: In my main method I startup connection with the websocket, after that I call the webservice for a resource. Now the problem is I have to try several times before a call to the webservice is made. Its a very strange bug. I tried initializing the websocket on a different thread but I still get the same problem. Please see the code below
Bank webservice:
//relevant import statements
#WebService(serviceName = "BankService")
public class BankService {
private static final Map<Integer, AccountHolder> accountHolders = new ConcurrentHashMap<Integer, AccountHolder>();
private static AccountHolder customer, merchant;
public BankService(){
customer = new AccountHolder("Customer 1", 1234, 4321, 4000, null, null);
merchant = new AccountHolder("Merchant", 5678, 8765, 1000, null, null);
accountHolders.put(1234, customer);
accountHolders.put(5678, merchant);
}
#WebMethod(operationName = "getBalance")
public String getBalance(#WebParam(name = "acctNum") int acctNum) {
AccountHolder client;
synchronized(accountHolders){
client = accountHolders.get(acctNum);
}
return client.toString(); //returns a string containing balance
}
}
Bank notification websocket:
#ServerEndpoint(value="/n")
public class NotificationServer {
private Logger logger = Logger.getLogger(this.getClass().getName());
#OnOpen
public void onOpen(Session session) throws InterruptedException, IOException {
logger.info("Connected ... " + session.getId());
}
#OnMessage
public void notifyCustomer(String message, Session session) throws InterruptedException, IOException {
session.getBasicRemote().sendText(message);
}
#OnClose....
}
Client
public class Client {
static Client client;
private String getBalance(int acctNum) {
BankService_Service service = new BankWebService.BankService_Service();
BankService port = service.getBankServicePort();
return port.getBalance(acctNum);
}
private void wsc() throws InterruptedException {
BankNotificationClient bnc = new BankNotificationClient();
Thread thread = new Thread(bnc);
thread.start();
}
public static void main(String[] args) throws InterruptedException {
client = new Client();
client.wsc();
Scanner scanner = new Scanner(System.in);
while(!"quit".equals(scanner.next())){
if(scanner.next().equals("check")){
System.out.println(client.getBalance(1234));
}
}
}
}
Bank notification client:
//necessary import statements
import javax.*;
import org.glassfish.tyrus.client.ClientManager;
#ClientEndpoint
public class BankNotificationClient implements Runnable {
private static Session clientSession;
private Logger logger = Logger.getLogger(this.getClass().getName());
ClientManager clientws;
#OnOpen
public void onOpen(Session session) throws InterruptedException {
logger.info("Connected ... " + session.getId());
clientSession = session;
}
#OnMessage
public void onMessage(String message, Session session) {
....
}
#OnClose
public void onClose(Session session, CloseReason closeReason) {
logger.info(String.format("Session %s has closed because %s", session.getId(), closeReason));
}
public void run() {
try {
client = ClientManager.createClient();
client.connectToServer(BankNotificationClient.class, new URI("ws://localhost:8080/BankService/n"));
System.out.println("working" + client.getClass());
} catch (DeploymentException | URISyntaxException e) {
logger.info("Something has gone wrong initializing the socket");
}
}
}
I am using netbeans 8.0.2 as my development IDE. Having deployed the webservice and websocket to glassfish server 4.1. Running this would give the following output
Output:
Aug 05, 2015 11:31:18 PM BankNotificationHandler.BankNotificationClient onOpen
INFO: Connected ... 981de7b4-91b9-43b6-beaf-c219500ee77a
check
check
Dear Customer Customer 1, your account balance is 4000.
check
check
Dear Customer Customer 1, your account balance is 4000.
check
check
Dear Customer Customer 1, your account balance is 4000.
As you can see from the output I have to type and enter "check" twice before I get a result from the webservice. Using a debugger on the first entry of check the code suddenly halts at the if statement in the while loop, then I have to enter "check" again. On entering check it continues from where it stopped in the if statement line and proceeds to give me the desired result.
Please let me know if there is any other information I have left out.
Cheers.

Related

OutOfMemoryError: Direct buffer memory when using websockets in WildFly

After a while on our WildFly 18 server, in production, we encountered this error:
[org.xnio.listener] (default I/O-1) XNIO001007: A channel event listener threw an exception:
java.lang.OutOfMemoryError: Direct buffer memory
at java.base/java.nio.Bits.reserveMemory(Bits.java:175)
at java.base/java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118)
at java.base/java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317)
at org.jboss.xnio#3.7.3.Final//org.xnio.BufferAllocator$2.allocate(BufferAllocator.java:57)
at org.jboss.xnio#3.7.3.Final//org.xnio.BufferAllocator$2.allocate(BufferAllocator.java:55)
at org.jboss.xnio#3.7.3.Final//org.xnio.ByteBufferSlicePool.allocateSlices(ByteBufferSlicePool.java:162)
at org.jboss.xnio#3.7.3.Final//org.xnio.ByteBufferSlicePool.allocate(ByteBufferSlicePool.java:149)
at io.undertow.core#2.0.27.Final//io.undertow.server.XnioByteBufferPool.allocate(XnioByteBufferPool.java:53)
at io.undertow.core#2.0.27.Final//io.undertow.server.protocol.framed.AbstractFramedChannel.allocateReferenceCountedBuffer(AbstractFramedChannel.java:549)
at io.undertow.core#2.0.27.Final//io.undertow.server.protocol.framed.AbstractFramedChannel.receive(AbstractFramedChannel.java:370)
at io.undertow.core#2.0.27.Final//io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:38)
at io.undertow.core#2.0.27.Final//io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:33)
at org.jboss.xnio#3.7.3.Final//org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at io.undertow.core#2.0.27.Final//io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:950)
at io.undertow.core#2.0.27.Final//io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:931)
at org.jboss.xnio#3.7.3.Final//org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.jboss.xnio#3.7.3.Final//org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
at org.jboss.xnio.nio#3.7.3.Final//org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
at org.jboss.xnio.nio#3.7.3.Final//org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
We checked a JVM dump through jxray, and it seems websockets are the culprit:
Fact is that our websocket is kind of straightforward:
#ApplicationScoped
#ServerEndpoint(value = "/ws/messenger/{accountId}")
public class MessengerSocket implements Serializable
{
private static final long serialVersionUID = -3173234888004281582L;
#Inject
private Logger log;
#Inject
private MessengerHandler handler;
#OnOpen
public void onOpen(#PathParam("accountId") String accountId, Session session, EndpointConfig config)
{
log.debug("Opening for {}", accountId);
handler.subscribeSocket(session, UUID.fromString(accountId));
}
#OnClose
public void onClose(#PathParam("accountId") String accountId, Session session, CloseReason closeReason)
{
log.debug("Closing {}", accountId);
handler.unsubscribeSocket(session, UUID.fromString(accountId));
}
}
It's coupled with a simple handler, managing a map of users sessions:
#ApplicationScoped
public class MessengerHandler
{
#Inject
private Logger log;
// key: Account id
private Map<UUID, AccountMessengerSessions> sessions;
public void init()
{
sessions = new ConcurrentHashMap<>();
}
public void subscribeSocket(Session session, UUID accountId)
{
// build and store the account messenger session if new
AccountMessengerSessions messenger = sessions.getOrDefault(accountId, new AccountMessengerSessions(accountId));
messenger.getWsSessions().add(session);
sessions.putIfAbsent(accountId, messenger);
log.debug("{} has {} messenger socket session(s) (one added)", messenger.getAccountId(), messenger.getWsSessions().size());
}
/**
* Unsubscribes the provided WebSocket from the Messenger.
*/
public void unsubscribeSocket(Session session, UUID accountId)
{
if (!sessions.containsKey(accountId))
{
log.warn("Ignore unsubscription from {} socket, as {} is unknwon from messenger", session.getId(), accountId);
return;
}
AccountMessengerSessions messenger = sessions.get(accountId);
messenger.getWsSessions().remove(session);
log.debug("{} has {} messenger socket session(s) (one removed)", messenger.getAccountId(), messenger.getWsSessions().size());
if (!messenger.getWsSessions().isEmpty())
{
return;
}
// no more socket sessions, fully remove
sessions.remove(messenger.getAccountId());
}
}
Client side, we have a bit of javascript called when a page is loaded, again, nothing fancy:
var accountId = // some string found in DOM
var websocketUrl = "wss://" + window.location.host + "/ws/messenger/" + accountId;
var websocket = new WebSocket(websocketUrl);
websocket.onmessage = function (event) {
var data = JSON.parse(event.data);
// nothing fancy here...
};
Our users don't use a lot the feature offered by the websocket (an instant messenger), so what is really happening in production is basically websockets opening and closing at each page, with very few messages sent through.
Where could we get it wrong and create this buffer leak? Did we forget something critical?
Looking at this post this may happen if you have a lot of CPU. This was solved by decreasing the number of IO workers. Not sure if this can help in your case.
I also had a similar problem on our wildfly 18 (wildfly 19 suffers from it, too). It is probably triggered by a faulty xnio lib inside wildfly. After updating to wildfly 22 (using the latest xnio lib) the problem was gone.

can't get echo response from ws://echo.websocket.org in my websocket client

I'm trying to implement a simple websocket client in java using the javax websocket library, here's my code:
import java.io.IOException;
import java.net.URI;
import javax.websocket.*;
#ClientEndpoint
public class Client {
Session session;
private final static String url = "ws://echo.websocket.org";
public static void main(String[] args) throws Exception, IOException {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
System.out.println("connecting...");
container.connectToServer(Client.class,
URI.create(url));
}
#OnMessage
public void newMessage(String message, Session session) {
System.out.println(message);
}
#OnOpen
public void newConnection(Session session) throws IOException {
this.session = session;
System.out.println("The connection has been started");
session.getBasicRemote().sendText("hello");
}
#OnClose
public void disconnection() {
System.out.println("The connection has been ended");
}
}
As you can see in the #OnOpen annotation i try to send the "Hello" string message and on the #OnMessage i just want print the message in the console.
I can run the code without errors, but i just got the "connecting..." print so can anyone explain what is wrong with the code?
Note: i added the org.glassfish.tyrus libraries that's needed to work with the javax.websocket to the referenced libraries as well
I'm newbie in Java so sorry for the dumb question
Your program is exiting immediately after calling container.connectToServer(...) so your newConnection(...) and newMessage(...) functions never get a chance to run. You need to keep your program running after the call to container.connectToServer(...). You can do this by, for example, adding the following code after the container.connectToServer(...) line which will cause the program to wait for the ENTER key to be pressed:
System.out.println("Press ENTER key to exit.");
System.in.read();
After making that change, your program worked correctly on my computer and displayed the "The connection has been started" and "hello" messages.

How to implement websocket with Struts 2

I'm currently using Struts 2 as my framework and I need to have a Websocket feature so I can communicate with my client that is accessing it through HTML Websocket.
I have tried to use Java Websocket API (JSR 356) with Java application running on Tomcat 7.0.56. However, when I try it with Struts 2 framework, it does not work.
Some researches that I did suggested that it could have been because of the way Struts 2 maps the URL, but to no avail, I am still unable to communicate with the Websocket endpoint on my server.
Do anyone have any idea how to implement Websocket with Struts 2 framework?
The code that I used for the websocket is as follow:
#ServerEndpoint("/mssendpoint")
public class MSSEndpoint {
public static Logger logger = Logger.getLogger(MSSEndpoint.class);
/* Queue for all open WebSocket sessions */
static Queue<Session> queue = new ConcurrentLinkedQueue<Session>();
static Set<WebsocketListener> listeners = new HashSet<WebsocketListener>();
public static void send(String msg) {
try {
/* Send updates to all open WebSocket sessions */
for (Session session : queue) {
session.getBasicRemote().sendText(msg);
logger.info("Sent: " + msg);
}
}
catch (IOException e) {
logger.error(e.toString());
}
}
#OnOpen
public void openConnection(Session session) {
/* Register this connection in the queue */
queue.add(session);
logger.info("Connection opened.");
}
#OnClose
public void closedConnection(Session session) {
/* Remove this connection from the queue */
queue.remove(session);
logger.info("Connection closed.");
}
#OnError
public void error(Session session, Throwable t) {
/* Remove this connection from the queue */
queue.remove(session);
logger.info(t.toString());
logger.info("Connection error.");
}
#OnMessage
public void onMessage(String message, Session session) {
if (queue.contains(session)) {
notifyListener(message);
}
}
public static void addListener(WebsocketListener listener){
listeners.add(listener);
}
public static void removeListener(WebsocketListener listener){
listeners.remove(listener);
}
public void notifyListener(String message){
for (WebsocketListener listener : listeners) {
listener.onMessage(message);
}
}
}
I have used this exact same code on normal Java Servlet application running on Tomcat 7.0.56 and with a client, I could connect to it.
I used 'Simple Websocket Client' chrome extension as the client.
All I need was to connect to ws://localhost/myprojectname/mssendpoint and it will connect directly.
EDIT2:
I forgot to mention that the error was that when I tried to connect, it will simply say undefined when I use the Websocket Client. Assuming that my Struts 2 project is called cms, by right I should just need to access ws://localhost/myprojectname/mssendpoint. But then it produces that undefined message.

How do I setup JSR356 websockets in a jetty container

I see lots of tutorials about how to set up JSR356 websockets with an embedded web server of some sort.
But I want to add some websockets to an existing WAR deployed to a stand alone jetty installation, jetty jetty-9.2.3.v20140905, and I can find very little information on this. I can't figure out what is preventing it from working. As I understand it, the annotated server endpoints should be automatically handled by jetty.
ServerEndpoint:
#ServerEndpoint(value = "/myendpoint")
public class MyServerEndpoint {
private Logger logger = Logger.getLogger(this.getClass().getName());
#OnOpen
public void onOpen(Session s) {
logger.info("Server Connected ... " + s.getId());
s.getAsyncRemote().sendText("You are connected to the websocket server");
}
#OnMessage
public void onMessage(String message, Session session) {
// Sent the message back to all connected users
logger.info("Server Session " + session + " Received string message " + message);
for(Session s: session.getOpenSessions()) {
if (s.isOpen()) {
s.getAsyncRemote().sendText(message + " server response");
}
}
}
#OnClose
public void onClose(Session session, CloseReason reason) {
logger.info("Server Session " + session + " closed for reason " + reason);
}
}
ClientEndpoint:
#ClientEndpoint
public class MyClientEndpoint {
private Logger logger = Logger.getLogger(this.getClass().getName());
#OnOpen
public void onOpen(Session s) {
logger.info("Client Connected ... " + s.getId());
s.getAsyncRemote().sendText("hello from the client!");
}
#OnMessage
public void onMessage(String message, Session session) {
logger.info("Client Session " + session + " Received string message " + message);
}
#OnClose
public void onClose(Session session, CloseReason reason) {
logger.info("Client Session " + session + " closed for reason " + reason);
}
}
Here is the code (run inside some existing method) to connect the client to the server
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://localhost:8080/myWar/myendpoint";
container.connectToServer(MyClientEndpoint.class, URI.create(uri));
Yet spinning up jetty gives an error on the connectToServer line
2014-10-30 12:26:58.658:WARN:oeja.ServletContainerInitializersStarter:main:
org.eclipse.jetty.websocket.api.InvalidWebSocketException: Unable to instantiate websocket: class java.lang.Class
at org.eclipse.jetty.websocket.jsr356.ClientContainer.newClientEndpointInstance(ClientContainer.java:311)
at org.eclipse.jetty.websocket.jsr356.ClientContainer.connectToServer(ClientContainer.java:172)
All I can think is that the URI is incorrect. If jetty is running on 8080 and my .war is named myWar, and my end point is named myendpoint...is that not the correct URI?
Is there some additional step that must be done to 'activate' the server endpoint to listen for connections? I must be missing something obvious.
Strangely, your error message.
org.eclipse.jetty.websocket.api.InvalidWebSocketException:
Unable to instantiate websocket: class java.lang.Class
Means that the websocket implementation was handed a raw java.lang.Class to instantiate.
That's not going to work.
It also means no attempt was made to connect, as the WebSocket class itself was so bad that a connect was impossible.
Here's a short (valid and working) example showing its use.
package jetty.jsr356;
import java.io.IOException;
import java.net.URI;
import java.util.concurrent.CountDownLatch;
import javax.websocket.ClientEndpoint;
import javax.websocket.CloseReason;
import javax.websocket.CloseReason.CloseCodes;
import javax.websocket.ContainerProvider;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;
#ClientEndpoint
public class TestClientAnnotatedClass
{
private static CountDownLatch closeLatch = new CountDownLatch(1);
#OnOpen
public void onOpen(Session session)
{
System.out.println("#OnOpen - " + session);
try
{
session.getBasicRemote().sendText("Rock it with Java WebSocket");
}
catch (IOException e)
{
e.printStackTrace();
}
}
#OnMessage
public void onMessage(Session session, String msg)
{
System.out.println("#OnMessage - ["+msg+"]");
try
{
session.close(new CloseReason(CloseCodes.NORMAL_CLOSURE,"Thanks"));
}
catch (IOException e)
{
e.printStackTrace();
}
}
#OnClose
public void onClose(CloseReason close)
{
System.out.println("#OnClose - " + close);
closeLatch.countDown();
}
public static void main(String[] args)
{
try
{
WebSocketContainer ws = ContainerProvider.getWebSocketContainer();
ws.connectToServer(TestClientAnnotatedClass.class,new URI("ws://echo.websocket.org/?encoding=text"));
closeLatch.await();
}
catch (Throwable t)
{
t.printStackTrace();
}
}
}
You'll see output similar to this
2014-10-30 11:34:19.197:INFO::main: Logging initialized #71ms
#OnOpen - WebSocketSession[websocket=JsrAnnotatedEventDriver[websocket=jetty.jsr356.TestClientAnnotatedClass#5cca5f2c],behavior=CLIENT,connection=WebSocketClientConnection#6a2e714b{IDLE}{f=Flusher[queueSize=0,aggregateSize=0,failure=null],g=Generator[CLIENT,validating],p=Parser#55465b1f[ExtensionStack,s=START,c=0,len=0,f=null,p=WebSocketPolicy#7e087bf5[behavior=CLIENT,maxTextMessageSize=65536,maxTextMessageBufferSize=32768,maxBinaryMessageSize=65536,maxBinaryMessageBufferSize=32768,asyncWriteTimeout=60000,idleTimeout=300000,inputBufferSize=4096]]},remote=WebSocketRemoteEndpoint#5f025277[batching=true],incoming=JsrAnnotatedEventDriver[websocket=jetty.jsr356.TestClientAnnotatedClass#5cca5f2c],outgoing=ExtensionStack[queueSize=0,extensions=[],incoming=org.eclipse.jetty.websocket.jsr356.JsrSession,outgoing=org.eclipse.jetty.websocket.client.io.WebSocketClientConnection]]
#OnMessage - [Rock it with Java WebSocket]
#OnClose - CloseReason[1000,Thanks]
Jetty creates instances of annotated client endpoints using reflection (see /jetty/websocket/jsr356/ClientContainer#newClientEndpointInstance()) but Java is unable to instantiate a non-static inner class that way. The actual cause exception is something like java.lang.NoSuchMethodException: <pkg>.OuterClass$InnerClass.<init>() but it is swallowed.
Solution: annotated endpoint classes should be not nested or nested static (inner) classes.

[Californium/CoAP/LWM2M]: Reusing message send endpoint for server not possible?

I am building a tool that can send CoAP messages to another peer (different implementation), but I am having difficulties. I am using the CoAP library called "Californium" and am developing the tool in java/eclipse. Here's the deal: I send a message over californium's "default endpoint", which allows the system to make up a source-port for the UDP "connection". I want to listen on this same source-port using californium's Server object, but I am getting the following error:
SEVERE: Could not start endpoint
java.net.BindException: Address already in use
So my question is: how do I first send a CoAP message and start listening for other CoAP messages on the same socket using Californium?
Below is the java code for the client. What it does is "register" using a certain protocol layered on top of CoAP. After registering I want it to re-use the UDP socket for listening for subsequent messages of the entity I registered with earlier.
NOTE: The server part of the client works when I explicitly tell it to listen to a certain port (e.g. 5683), leave out the register part and test it with the Firefox Addon "Copper" (i.e. Copper can get to the /1 /1/1 /1/1/0 resources).
package com.example.l2mwm.client;
import java.net.InetSocketAddress;
import ch.ethz.inf.vs.californium.coap.CoAP.Code;
import ch.ethz.inf.vs.californium.coap.CoAP.ResponseCode;
import ch.ethz.inf.vs.californium.coap.CoAP;
import ch.ethz.inf.vs.californium.coap.Request;
import ch.ethz.inf.vs.californium.coap.Response;
import ch.ethz.inf.vs.californium.network.Endpoint;
import ch.ethz.inf.vs.californium.network.EndpointManager;
import ch.ethz.inf.vs.californium.server.Server;
import ch.ethz.inf.vs.californium.server.resources.CoapExchange;
import ch.ethz.inf.vs.californium.server.resources.Resource;
import ch.ethz.inf.vs.californium.server.resources.ResourceBase;
public class Main {
public static void main(String[] args) {
Endpoint endpoint;
if ((endpoint = register()) != null) {
listen(endpoint);
} else {
System.out.println("Couldn't register!");
}
}
private static void listen(Endpoint endpoint) {
InetSocketAddress sockAddress = endpoint.getAddress();
int port = sockAddress.getPort();
Server server = new Server(port);
Resource topResource = new ResourceBase("1") {
#Override
public void handleGET(CoapExchange exchange) {
exchange.respond(ResponseCode.CONTENT, "this is /1's value!");
}
#Override
public String getPath() {
return "/";
}
};
Resource instanceResource = new ResourceBase("1") {
#Override
public void handleGET(CoapExchange exchange) {
exchange.respond(ResponseCode.CONTENT, "this is /1/1's value!");
}
#Override
public String getPath() {
return "/1/";
}
};
topResource.add(instanceResource);
instanceResource.add(new ResourceBase("0") {
#Override
public void handleGET(CoapExchange exchange) {
exchange.respond(ResponseCode.CONTENT, "this is /1/1/0's value!");
}
#Override
public String getPath() {
return "/1/1/";
}
});
server.add(topResource);
server.start();
}
private static Endpoint register() {
Request request = new Request(Code.POST);
request.setURI("localhost:5684/rd?ep=coapclient&lt=86400&b=U");
request.setPayload("</1/1/0>");
Endpoint endpoint = EndpointManager.getEndpointManager().getDefaultEndpoint();
request.send(endpoint);
Response response;
ResponseCode responseCode = null;
try {
response = request.waitForResponse();
} catch (InterruptedException e) {
System.out.println(e.getMessage());
return null;
}
responseCode = response.getCode();
if (responseCode != CoAP.ResponseCode.CREATED) {
return null;
}
return endpoint;
}
}
You need to first bind your UDP socket and then start your LWM2M register.
Because what you do: create CoAP Endpoint (bind a udp server) and than you bind again in your listen method.
// list to the UDP post 5555
coapServer = new Server();
Endpoint endpoint = new CoAPEndpoint(new InetSocketAddress("localhost",5555);
coapServer.addEndpoint(endpoint);
// send a message to a LWM2M server:
request request = new Request(Code.POST);
request.setURI("iot.eclipse.org:5683/rd?ep=coapclient&lt=86400&b=U");
request.setPayload("</1/1/0>");
Endpoint endpoint = EndpointManager.getEndpointManager().getDefaultEndpoint();
request.send(endpoint);
You can still access to your client using copper on coap://localhost:5555

Categories