Last active
November 1, 2021 23:10
-
-
Save alex-hladun/f7b79d9fd23c067cdeb253fac9aecca9 to your computer and use it in GitHub Desktop.
Connecting Socket.io to our server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
generateSocketServer = (server: http.Server) => { | |
// Socket server property | |
this.io = new Server(server, { | |
cors: { | |
// Would change origin to eventual DNS for react app if | |
// uploaded to S3 instead of served. | |
origin: "http://localhost:3000", | |
methods: ["GET", "POST"], | |
credentials: true | |
}, | |
allowEIO3: true, // Whether to enable compatibility with Socket.IO v2 clients. | |
maxHttpBufferSize: 1024, // max message payload size (prevents clients from sending gigabytes of data) | |
pingInterval: 45 * 1000, // 45 seconds (less than ALB timeout) | |
pingTimeout: 4 * 60 * 1000 // 4 minutes | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment