Java-OCA-OCPP
Java-OCA-OCPP copied to clipboard
the example can not run ,the client send msg but the server cont not receiver msg
the example can not run ,the clint send msg but the server cont not receiver msg for example:
the server: public static void main(String[] args) { JSONServerSample jsonServer = new JSONServerSample(); try { jsonServer.started(); //jsonServer.sendClearCacheRequest(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }
}
the client: public static void main(String[] args) throws Exception { JSONClientSample jsonClient = new JSONClientSample();
try {
jsonClient.connect();
jsonClient.sendBootNotification();
Thread.sleep(100000L);
jsonClient.disconnect();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Hi @lizhichao999
The sample server should print to console. If you don't see that, you should check your firewall.
@TVolden 1.How to send messages on the server side and the client accept 2,if the server class method handleBootNotificationRequest return new BootNotificationConfirmation();rp why the client can not print anything , client.send(request).whenComplete((s, ex) ->{
System.out.println("=================");
System.out.println("---->"+s);
ex.printStackTrace();
});
Hi @lizhichao999
In the sample code I provide, you can call sendClearCacheRequest() to try a server to client request. If you want the server/client to send other requests, you have to implement them yourself :)
Hmm. I never thought about this, but my sample code, would not be able to communicate out of the box.
It would be nice, if the client didn't return a not implemented error when the server sends a clear cache request and wise versa for the server when the client sends a boot notification request.
Anyway, if you instantiated a BootNotificationConfirmation and set the required fields (status, currentTime and interval), then the client should receive the response.
Any news on this issue @lizhichao999?