Java-OCA-OCPP icon indicating copy to clipboard operation
Java-OCA-OCPP copied to clipboard

the example can not run ,the client send msg but the server cont not receiver msg

Open lizhichao999 opened this issue 7 years ago • 4 comments

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();
	}
}

lizhichao999 avatar Sep 13 '18 03:09 lizhichao999

Hi @lizhichao999

The sample server should print to console. If you don't see that, you should check your firewall.

TVolden avatar Sep 13 '18 05:09 TVolden

@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();
    });

lizhichao999 avatar Sep 13 '18 12:09 lizhichao999

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.

TVolden avatar Sep 13 '18 13:09 TVolden

Any news on this issue @lizhichao999?

TVolden avatar Oct 20 '18 14:10 TVolden