0

I have set up an OCPP web socket server in .Net Core where all charge point communicates with my OCPP server. And as per OCPP-j 1.6's suggestion initially, all chargers have the same default password, and when they first time communicate with the server via WebSocket, then it is our server's job to validate the initial password, create a new password and send a configuration change request to change the new password and close the WebSocket so that it forces charge point to use the new key.

This is where I handle my WebSocket protocol, right now I am just implementing 1.6. But, we have a step Receive16() where every request will be handled, but for now, I am just sending myself an email just to confirm if the charger has connected to the WebSocket server.

using (WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync(subProtocol))
{
       _logger.LogTrace("OCPPMiddleware => WebSocket connection with charge point '{0}'", chargepointIdentifier);
       chargePointStatus.WebSocket = webSocket;

       if (subProtocol == Protocol_OCPP20)
       {
             // OCPP V2.0 not added => NotImplemented
             _logger.LogWarning("OCPP Web Socket => OCPP 2.0 request");
             context.Response.StatusCode = (int)HttpStatusCode.NotImplemented;
       }
       else
       {
             // OCPP V1.6
             // await Receive16(chargePointStatus, context);
             _ = _emailSender.SendEmailAsync("tets@email.com", "Charger connected to websocket", vendorChargerIdentifier + " connected to websocket");
       }
}

I do get an email but in the Zaptec dashboard I can see the following error:

Not connected to OCPP server.
Jun 29, 2023 10:04 AM
Message listener was stopped due to a WebSocketException; System.Net.WebSockets.WebSocketException The remote party closed the WebSocket connection without completing the close handshake. (errorCode: 0).

So can anyone help me with the authorization if the request came from the correct Charge Point and changing if it is the initial default password and the close handshake error in the dashboard?

0 Answers0