Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket is not open: readyState 3 #4

Closed
yonas124 opened this issue Jan 16, 2020 · 17 comments
Closed

WebSocket is not open: readyState 3 #4

yonas124 opened this issue Jan 16, 2020 · 17 comments

Comments

@yonas124
Copy link

Hello, I'm currently testing the 'CS server' with 2 chargebox connected. When I send command over 'CS request JSON' node, occasionally it gives "error: WebSocket is not open: readyState 3 (CLOSED)" and I had to restart the flow.

Any idea?

@mingyi621
Copy link

Uncomment line 351 and 352 in ocpp/ocpp-server.js can resolve the issue.

@yonas124
Copy link
Author

yonas124 commented Mar 8, 2020

After days lf observing, it seems like the websocket error is no longer there but from time to time the Charging Station got disconnected and the flow must be restarted.
Any idea why?

I put 2 hours in nodered websocket timeout setting.

@gvregulvar
Copy link

Hello,

i also had the same problem recently. It usually happens over night. When i wake up in the morning, i can't send commands to the charging stations.

did the 2 hours timeout work out for you @yonas124 ?

@yonas124
Copy link
Author

@gvregulvar I put periodic 'GetConfig' command to make sure the socket is ready to receive command but no, the timout didn't work for me, CS disconnected after 1-2 hours randomly. I ended up reverting to its default condition, no timeout configured.

It's less stable with 2 or more CS connected.

What's your setup?

@gvregulvar
Copy link

@yonas124 I have 2 charging stations, OCPP 1.6j. I wish i had 4+ to test, but i dont think its going to happen for now. The server is on a mini-pc with a lightweight linux and on the same network as the charging stations.

How often do you send a getconfig? Wouldn't sending a "none" command work?

What i don't understand is that if the websocket is closed, why do i still get meter values from the charging stations but commands drop with errors? Shouldn't it be both?

@yonas124
Copy link
Author

@gvregulvar yes, my thought as well, but the error is only from CP to CS (commands). I send it every hour to check if the server receive any reply or not.
My setup is a bit different, it's in a cloud VPS with 3 chargers connecting over 3G/4G sim.

@gvregulvar
Copy link

Strangely enough, i didn't have any charging stations disconnect from my server this morning...

@gvregulvar
Copy link

@yonas124 Im curious, how much data are you using with the charging stations sending data (on 4g) every x amount of time?

@gvregulvar
Copy link

Im getting closed websockets even while sending queries now. Have you tried the solution @mingyi621 talked before @yonas124?

@yonas124
Copy link
Author

@gvregulvar I have and as I mentioned before, no error but after a while charger doesn't respond to query from server. This is why I setup periodic query sending to check if there's any reply or not.

@gvregulvar
Copy link

Oh i didn't catch that. Thanks for replying. Sorry for tagging you twice in a row, wasn't intended.

Have a good one!

@gvregulvar
Copy link

I just wanted to update the thread in case someone land here from google :

The workaround proposed by yonas along with the first solution by ming works 100%. I had the server open for 3 days without a reset and the websockets are still going strong.

@yonas124
Copy link
Author

@gvregulvar how is it going so far?
I still have some issue with charger doesn't respond to query from server after several hours after restarting flow, and it requires restart again.

I also notice that node-red is actually listening on tcp6 instead of tcp

@JasonStonier
Copy link

I have a very similar problem which I can make repeatable for testing: if the CS is running and and communicating, but then I power cycle the charge point, the CP send a boot notification up to the CS which is received, but the CS cannot send commands back down to the CP because it is communicating (I believe) on the old Web Socket.

The way to fix this is to restart the flow, which re-establishes all the Web Sockets - which is ok if you have 1 CP, but if you have 2 or more it's not a great way of doing things because you could kill a session on one that's working perfectly.

What I would love is a way to restart individual web sockets on a CP basis - is that possible?

@JasonStonier
Copy link

By the way, we did the trick of uncommenting lines 351 and 352 which allows (as far as I can see) the listener service to close a web socket, and it appears to have solved my problem - at least in the short tests we've done today.

@sro49-iot
Copy link

Hello,

I use Node Red OCPP on some embedded devices to manage some charge box. I have websocket error randomly and don't know why it happens. I can't easily modify or uncomment line 350/351 of server file. You can find below some logs made today with no problem during car charging with remote start and end of charge. But after some RFID tests we got websocket error.

// Car charging with remoteStartTransaction
1 Feb 09:32:13 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3564","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","info":"EVconnected","status":"Preparing","timestamp":"2022-02-01T08:32:09Z"}}}
1 Feb 09:32:49 - {"cbId":"00:80:F4:XX:YY:ZZ","command":"RemoteStartTransaction","data":{"connectorId":1,"idTag":"123456789ABCDE"}}
1 Feb 09:32:53 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3565","msgType":2,"command":"StartTransaction"},"payload":{"command":"StartTransaction","data":{"connectorId":1,"idTag":"123456789ABCDE","meterStart":0,"timestamp":"2022-02-01T08:32:53Z"}}}
1 Feb 09:32:56 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3566","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"Charging","timestamp":"2022-02-01T08:32:54Z"}}}
1 Feb 09:47:54 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3574","msgType":2,"command":"MeterValues"},"payload":{"command":"MeterValues","data":{"connectorId":1,"meterValue":[{"sampledValue":[{"value":"2664"}],"timestamp":"2022-02-01T08:47:52Z"}],"transactionId":45185}}}
1 Feb 10:02:53 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3582","msgType":2,"command":"MeterValues"},"payload":{"command":"MeterValues","data":{"connectorId":1,"meterValue":[{"sampledValue":[{"value":"5365"}],"timestamp":"2022-02-01T09:02:52Z"}],"transactionId":45185}}}
...
1 Feb 13:32:53 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3694","msgType":2,"command":"MeterValues"},"payload":{"command":"MeterValues","data":{"connectorId":1,"meterValue":[{"sampledValue":[{"value":"43266"}],"timestamp":"2022-02-01T12:32:52Z"}],"transactionId":45185}}}
1 Feb 13:46:16 - {"cbId":"00:80:F4:XX:YY:ZZ","command":"RemoteStopTransaction","data":{"transactionId":37059}}
1 Feb 13:46:16 - {"cbId":"00:80:F4:XX:YY:ZZ","command":"RemoteStartTransaction","data":{"connectorId":1,"idTag":"123456789ABCDE"}}
1 Feb 13:46:17 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3701","msgType":2,"command":"StopTransaction"},"payload":{"command":"StopTransaction","data":{"meterStop":45681,"reason":"Remote","timestamp":"2022-02-01T12:46:16Z","transactionId":45185}}}
1 Feb 13:46:18 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3702","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"Finishing","timestamp":"2022-02-01T12:46:16Z"}}}
1 Feb 13:46:32 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3703","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"Available","timestamp":"2022-02-01T12:46:30Z"}}}

// Some RFID test
1 Feb 13:47:28 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3704","msgType":2,"command":"Authorize"},"payload":{"command":"Authorize","data":{"idTag":"01383309"}}}
1 Feb 13:47:29 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3705","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"Preparing","timestamp":"2022-02-01T12:47:27Z"}}}
1 Feb 13:47:59 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3706","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"Available","timestamp":"2022-02-01T12:47:57Z"}}}
1 Feb 13:48:38 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3707","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","info":"EVconnected","status":"Preparing","timestamp":"2022-02-01T12:48:35Z"}}}
1 Feb 13:49:19 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3708","msgType":2,"command":"Authorize"},"payload":{"command":"Authorize","data":{"idTag":"01383309"}}}
1 Feb 13:49:22 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3709","msgType":2,"command":"StartTransaction"},"payload":{"command":"StartTransaction","data":{"connectorId":1,"idTag":"01383309","meterStart":0,"timestamp":"2022-02-01T12:49:21Z"}}}
1 Feb 13:49:24 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3710","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"SuspendedEVSE","timestamp":"2022-02-01T12:49:22Z"}}}
1 Feb 13:49:26 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3711","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"Charging","timestamp":"2022-02-01T12:49:24Z"}}}
1 Feb 13:51:09 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3712","msgType":2,"command":"StopTransaction"},"payload":{"command":"StopTransaction","data":{"meterStop":296,"reason":"Remote","timestamp":"2022-02-01T12:51:07Z","transactionId":96691}}}
1 Feb 13:51:11 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3713","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"Finishing","timestamp":"2022-02-01T12:51:07Z"}}}

// charge box reboot
1 Feb 13:53:48 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"1","msgType":2,"command":"BootNotification"},"payload":{"command":"BootNotification","data":{"chargeBoxSerialNumber":"EVB1A22P4ERI3N1838xxxxxxxx","chargePointModel":"EVlink Smart Wallbox","chargePointSerialNumber":"3N18XXXXXX","chargePointVendor":"Schneider Electric","firmwareVersion":"3.4.0.3"}}}
1 Feb 13:53:51 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"2","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"Available","timestamp":"2022-02-01T12:53:47Z"}}}
1 Feb 13:54:07 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"3","msgType":2,"command":"Authorize"},"payload":{"command":"Authorize","data":{"idTag":"01A2EDC5"}}}
1 Feb 13:54:09 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"4","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"Preparing","timestamp":"2022-02-01T12:54:06Z"}}}
1 Feb 13:54:39 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"5","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"Available","timestamp":"2022-02-01T12:54:36Z"}}}

// Inoperative remote command try
1 Feb 13:58:26 - {"cbId":"00:80:F4:XX:YY:ZZ","command":"ChangeAvailability","data":{"connectorId":1,"type":"Inoperative"}}
1 Feb 13:58:27 - [error] [CS request JSON:Get config] Error: WebSocket is not open: readyState 3 (CLOSED)

// RFID try
1 Feb 14:00:51 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"9","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","info":"EVconnected","status":"Preparing","timestamp":"2022-02-01T13:00:48Z"}}}
1 Feb 14:01:15 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"10","msgType":2,"command":"Authorize"},"payload":{"command":"Authorize","data":{"idTag":"0780BA2305496E"}},"msgId":"45fa2df0-382c-48ce-8a09-2f1e787838c9"}
1 Feb 14:01:18 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"11","msgType":2,"command":"StartTransaction"},"payload":{"command":"StartTransaction","data":{"connectorId":1,"idTag":"0780BA2305496E","meterStart":0,"timestamp":"2022-02-01T13:01:17Z"}}}
1 Feb 14:01:20 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"12","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"SuspendedEVSE","timestamp":"2022-02-01T13:01:17Z"}}}
1 Feb 14:01:22 - {"ocpp":{"chargeBoxIdentity":"00:80:F4:XX:YY:ZZ","MessageId":"13","msgType":2,"command":"StatusNotification"},"payload":{"command":"StatusNotification","data":{"connectorId":1,"errorCode":"NoError","status":"Charging","timestamp":"2022-02-01T13:01:19Z"}}}

// get last statusNotification command not listed in debug
1 Feb 14:01:36 - [error] [CS request JSON:Get config] Error: WebSocket is not open: readyState 3 (CLOSED)

Do you thinkuncomment line 350 and 351 will solve problem all the time? Why there is no new version if it fixes Websocket error?
Do you have any other Linux command to close websocket or manage TCP connection?

@bnystrom
Copy link
Collaborator

bnystrom commented Feb 6, 2023

Sorry this sat for so long. Merged in the uncommenting of the two referenced lines in the server code.
Fixed in v1.3.2
#34 #35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants