mikuso / ocpp-rpc

A Node.js client & server implementation of the WAMP-like RPC-over-websocket system defined in the OCPP-J protocols.
MIT License
94 stars 28 forks source link

Correct way to send a handshake or connect #61

Open Tarekmo110 opened 1 year ago

Tarekmo110 commented 1 year ago

I'm trying to simulate a charge point and connect to the server. I think the server is working fine but the problem is how i connect to it. I'm using this to connect const newSocket = new WebSocket(${ocppJEndpointUrl}/${encodeURIComponent(chargePointIdentity)},['ocpp1.6', 'ocpp1.5']); so it should look like this ws://localhost:3000/ABCD with protocols [ocpp1.6,ocpp1.5] this is the error i get

const err = Error(reason); ^ Error [AbortError]: Client disconnected at Object.pendingCall.abort (/home/tarek/Desktop/ocpp_csms/server/node_modules/ocpp-rpc/lib/client.js:338:29) at /home/tarek/Desktop/ocpp_csms/server/node_modules/ocpp-rpc/lib/client.js:440:63 at Array.forEach () at RPCServerClient._rejectPendingCalls (/home/tarek/Desktop/ocpp_csms/server/node_modules/ocpp-rpc/lib/client.js:440:48) at RPCServerClient._handleDisconnect (/home/tarek/Desktop/ocpp_csms/server/node_modules/ocpp-rpc/lib/client.js:458:14) at WebSocket. (/home/tarek/Desktop/ocpp_csms/server/node_modules/ocpp-rpc/lib/client.js:410:49) at Object.onceWrapper (node:events:629:26) at WebSocket.emit (node:events:526:35) at WebSocket.emit (node:domain:489:12) at WebSocket.emitClose (/home/tarek/Desktop/ocpp_csms/server/node_modules/ws/lib/websocket.js:258:10)

mikuso commented 1 year ago

Hi,

Please can you clarify a few things for me?

Thanks.

Tarekmo110 commented 1 year ago

I will use it to create a central system but i was just testing things out first and familiarizing myself with this module.

I have a simple ui with a connect button that tries to establish a web-socket connection, as a charge point, with the server i created using the example you gave in express

I get this in the browser https://imgur.com/a/bzsPmKk

And I get this in the server https://imgur.com/a/WWyW64S I added some console.log to client.js

if u need any more info please let me know

mikuso commented 1 year ago

From your screenshots, it looks like the server is crashing, which is why your client's websocket is disconnecting.

Can we take a look at your server code to see what might be causing that to happen?