Closed mujinbao closed 1 year ago
same thing with https://github.com/websocket-client/websocket-client clients
I'd make a small example to demonstrate the issue (without the browser) and make easier to find the culprit.
Without that I can't give any help since it could be anything.
oh, and btw even when sending custom pings, it still gets disconnected after a while
As I said, it would be great to make a small code example to demonstrate this.
The code is very thoroughly tested but there could be a case not covered. But it could also be a simple issue like a network issue from your side.
As I said, it would be great to make a small code example to demonstrate this.
The code is very thoroughly tested but there could be a case not covered. But it could also be a simple issue like a network issue from your side.
not when this happens to every client (made with browsers , python, node, etc) on different devices and networks around the world, on a prod server. where clients are sending custom pings within a minute of the last one
also i know its this lib, because iv used a Async Websocket server and did not run into this problem (the server im working with is a 6 month old server, before they started to rewrite with aaugustin/websockets)
small example for the server im using (i only have accsess to jsfiddle RN so, browser)
const ws = new WebSocket("wss://server.meower.org")
ws.onopen = async () => {
// server protocol
ws.send(`{"cmd": "direct", "val": {"cmd": "type", "val": "js"}}`);
ws.send(`{"cmd": "direct", "val": {"cmd": "ip", "val": "${await fetch("https://api.meower.org/ip").then(res => res.text())}"}}`);
ws.send(`{"cmd": "direct", "val": "meower"}`);
setInterval(() => {
if (ws.readyState == 1) {
ws.send(`{"cmd": "ping", "val": ""}`);
}
}, 10000);
}
ws.onclose = async (event) => {
console.log(event)
}
I'm no Javascript expert but that await fetch
seems out of place in there. So see if commenting that line solves it for you.
I'm no Javascript expert but that
await fetch
seems out of place in there. So see if commenting that line solves it for you.
js fetch is async lmao, also yes that needs to be there
client is JavaScript, when the client sends "open camera", the server uses CV2(opencv-python) to open the camera and push each frame to the client.(I've converted the image to a Base64 string and assigned the src attribute of html Img'.)
But in the process of communication, the client often disconnects actively. According to my observation, there is no regularity in this anomaly , but the browser's console printed out an error
Google Chrome (version 71) -> failed: invalid frame header Google Chrome (version 68) -> failed: could not decode a text frame as utf8
@Pithikos Please help me , how can I sort out this problem? It's really a disgusting question.