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

114
Views
Configure websocket always to be open

I use this code to connect to NodeJS web socket:

useEffect(() => {      
        let futureResponseFeedAddress = "ws://localhost:/endpoint";
        const futureResponseClient = new W3CWebSocket(futureResponseFeedAddress);
        props.onUpdateOrderbookWebsocket(futureResponseClient);
        futureResponseClient.onopen = () => {
            console.log("WebSocket Client Connected on " + futureResponseFeedAddress);
        };
        futureResponseClient.onmessage = (message) => {
            ..............
        };
        futureResponseClient.onclose = closeEvent => {
            console.log("response messages websocket closed.");
        }

        return function cleanup() {
            futureResponseClient.close();
        };
    }, []); 

But after around 1-2 minutes the messages are not received. Looks like I get timeout. Do you know how I can configure the web socket to be always open?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

My suggestion is you should use socket.io for doing any real-time communication . It uses http long polling ,upgrades the connection to websocket if needed and it has also good browser support . It is much realiable too. But there are some drawbacks , your server need to use socket.io server api .

Socket.io-client

Socket.io-server

There is no need to re-invent the wheel .

about 4 years ago · Juan Pablo Isaza Report
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!