Try ERPNext Try Frappe Cloud Buy Support Partners Foundation

Frappe.publish_realtime not working on server console for portal page

Hello, I am trying to send socketio event from the server console. But the client does not receive it. The socketio on the client is working perfectly on port 9000. The socketio event from the server console works perfectly fine in desk view but not in an app’s portal page.
js code:

frappe.require("assets/frappe/js/lib/socket.io.min.js");
frappe.require("assets/frappe/js/frappe/socketio_client.js");
if (window.dev_server) {
    frappe.boot.socketio_port = '9000'
 }
frappe.socketio.init();
frappe.realtime.on('test', (data) => {
    console.log(data)
 });

console code:

frappe.publish_realtime('test' , {'test': 'test'})

Any help regarding this would be hugely appreciated!

In which file you written client side code?

I wrote the code in the www/test.js folder which has a test.html file.