Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1818

Socket.IO not working on AWS with NGINX, Node.js, and HTTPS (400 Bad Request on WebSocket)

$
0
0

I'm running a Node.js application with HTTPS and Socket.IO on an AWS EC2 instance, behind NGINX. The REST APIs work fine, but the WebSocket connection to Socket.IO fails with a 400 Bad Request.

const app = express();const { createServer } = require("http");  // Use HTTP not HTTPSconst { Server } = require("socket.io");const httpServer = createServer(app);const io = new Server(httpServer, {  cors: {    origin: ['https://abcdDomain.com', 'http://localhost:3000'],    methods: ["GET", "POST"],    credentials: true  }});io.on("connection", (socket) => {  console.log("Socket connected:", socket.id);});httpServer.listen(3001, () => {  console.log("HTTP server running on port 3001");});

Viewing all articles
Browse latest Browse all 1818

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>