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连接 #83

Open
FuYan opened this issue Nov 5, 2024 · 5 comments

Comments

@FuYan
Copy link

FuYan commented Nov 5, 2024

客户端意外断开连接后,服务器未针对心跳超时关闭websocket连接,导致_chargePointStatusDict 还存储了状态数据,而且此时通过api发送websocket消息会出现异常
private static Dictionary<string, ChargePointStatus> _chargePointStatusDict = new Dictionary<string, ChargePointStatus>();

@dallmann-consulting
Copy link
Owner

I'm not sure what the problem is. Your description is more than short.
The OCPP server does not manage the websocket connections. It relies on the ws connection status. If the connection closes the status in the dictionaray is removed. If a connection silently fails there might be a timeout interval until the connection officially gets closed. Of course all API calls will fail here as well.
But after both sides have noticed the failure they will close the dead connections and the charger can connect again. Thats the same for every tcp connection.

So where exactly is a problem in the OCPP server?

@FuYan
Copy link
Author

FuYan commented Nov 6, 2024

If the client unexpectedly disconnects and the dictionary is not removed, the management backend will display that the device is online when obtaining the status

@dallmann-consulting
Copy link
Owner

I couldn't really reproduce the issue on one machine. The connection always got closed friendly.
Please check the latest changes if that helps.

@KETRF
Copy link

KETRF commented Nov 8, 2024

I have also noticed this issue with NRGkick. When the client unexpectedly disconnects, the management backend still shows the device as online. If the problem occurs again, I will post the logs.

@FuYan
Copy link
Author

FuYan commented Nov 8, 2024

只需要对using (WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync(subProtocol)) 这里try catch 捕获异常处理就行了,
重现问题很简单, 浏览器连接上ocpp server后 直接在任务管理器结束掉浏览器进程就会出现,多试几次就知道
image

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

3 participants