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

278
Views
Falló la conexión de WebSocket a "wss://my_amazon_ec2_machine"

Actualicé mi sitio web al hacer que el nombre de dominio apunte a los servidores de Cloudflare, luego hice que Cloudflare apunte a mi servidor web. Antes de cambiar el sitio web de http a https y de us ws a wss, todo funcionaba bien, pero después seguía diciendo "Falló la conexión de WebSocket a "wss://server".

Lado del cliente:

 ws = new WebSocket('wss://ec2-3-97-91-10.ca-central-1.compute.amazonaws.com:443');

Lado del servidor:

 const express = require('express'); const https = require('https'); const WebSocket = require('ws'); const fs = require('fs'); var privateKey = fs.readFileSync('SSL PRIVATE KEY.key', 'utf8'); var certificate = fs.readFileSync('SSL CERTIFICATE.crt', 'utf8'); var credentials = {key: privateKey, cert: certificate}; const port = 443; var Application = express(); const server = https.createServer(credentials, Application); var wss = new WebSocket.Server({ server }) wss.on('connection', function connection(ws) { ws.on('message', function incoming(data) { wss.clients.forEach(function each(client) { if (client !== ws && client.readyState === WebSocket.OPEN) { client.send(data.toString()); } }) }) }) server.listen(port, function() { console.log(`Server is listening on ${port}!`) })

El certificado SSL y la clave privada se obtienen de cloudflare.

Si quieres el código completo, lo subí a un repositorio de github aquí: https://github.com/stampixel/stampixel.ga

El dominio que estoy usando es https://stampixel.ga

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!