Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
Connect to a pyzmq websocket from JS

I'm creating a websocket from a python file with zmq.

server.py

context = zmq.Context()
footage_socket = context.socket(zmq.PUB)
print ("socket created")
footage_socket.connect('tcp://192.168.1.15:1161')
print ("socket connected")
camera = cv2.VideoCapture(0)  # Init the camera

i = 0
while True:
    i += 1
    try:
        # print ("About to send ")
        # footage_socket.send(b"Hello ")
        # print ("Sent ")
        # time.sleep(1)
        # continue
        grabbed, frame = camera.read()  # Get the current frame
        frame = cv2.resize(frame, (640, 480))  # Resize the frame
        encoded, buffer = cv2.imencode('.jpg', frame)
        jpg_as_text = base64.b64encode(buffer)
        footage_socket.send(jpg_as_text)
        time.sleep(0.05)

    except KeyboardInterrupt:   # Stop the camera / stream
        camera.release()
        cv2.destroyAllWindows()
        break

I'm trying to connect to that Websocket with a js file :

Client.js

const { ipcRenderer } = require("electron");
var socket = new WebSocket('ws://192.168.1.15:1161')

document.addEventListener('DOMContentLoaded', (e) => {
    ipcRenderer.send('userInfo');
});


ipcRenderer.on('userInfo',(e,userInfo)=>{

        socket.onopen = function (data) {
            console.log(data + '_____________') 
          };

    });

but i get an error:

client.js:5 WebSocket connection to 'ws://192.168.1.15:1161/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

Can anybody explain me why ? and how to resolve ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!