Hi everyone!
I have Linux Zoom Bot, from bot i send data to WebSocket and try to retranslate this data to the frontend.
I’m proxy my WebSsocket to domain using nginx, after that I check connection and it work well.
However, I have next error in my Zoom App when I try get and show data
I’m add my domain to allow list, but it don’t help
This is my code for connect and get data in React
useEffect(() => {
// Establish WebSocket connection
const socket = io(`http://2675507-cd79415.twc1.net/${meetingID}/`, {
withCredentials: true
});
// Event listener for WebSocket messages
socket.on('message', function (message) {
// Log received data in console
console.log('Received:', message);
// Extract emotion and percentage from the message
const [prediction, percentage] = message.split(':');
const emotionKey = emotion.trim().toLowerCase();
console.log('Prediction:', prediction, " PredictionKey: ", predictionKey);
// Add emotion to buffer
setBuffer(prevBuffer => [...prevBuffer, emotionKey]);
});
return () => {
// Clean up WebSocket connection
socket.disconnect();
};
}, []);
And like this looks my WebSocket
const WebSocket = require("ws");
const http = require('http');
const WebSocketServer = new WebSocket.Server({ noServer: true });
function broadcast(message) {
WebSocketServer.clients.forEach(client => {
if (client.readyState === WebSocket.OPEN) {
console.log(message);
client.send(`[Linux Bot]: ${message}`);
}
});
}
WebSocketServer.on('connection', ws => {
// ws.id = UUID();
ws.on('message', message => broadcast(message));
});
const httpServer = http.createServer((req, res) => {
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*'); // Replace 'http://frontend:3000' with the actual URL of your frontend app
res.setHeader('Access-Control-Allow-Headers', '*');
res.setHeader('Access-Control-Request-Method', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET, POST, PUT, DELETE');
// Respond to preflight requests
if (req.method === 'OPTIONS') {
res.writeHead(200);
res.end();
return;
}
// Handle other HTTP requests here if needed
});
httpServer.on('upgrade', (request, socket, head) => {
WebSocketServer.handleUpgrade(request, socket, head, (ws) => {
WebSocketServer.emit('connection', ws, request);
});
});
httpServer.listen(8765, () => {
console.log('WebSocket server is running on port 8765');
});