Dear People,
I am trying to deploy my yjs project on aws. I put my react file on s3 and signal server on ec2.
I found out that webRtcProvider cannot connect to websocket signaling server.
This is my frontend code
export const doc = new Y.Doc();
export const provider = new WebrtcProvider(roomId, doc, {
signaling: ["ws://54.180.118.157:4444"],
awareness: new awarenessProtocol.Awareness(doc),
maxConns: 4,
filterBcConns: true,
peerOpts: {},
});
I copy and paste this below server code from :
https://github.com/yjs/y-webrtc/blob/master/bin/server.js
#!/usr/bin/env node
import ws from 'ws'
import http from 'http'
import * as map from 'lib0/map'
const wsReadyStateConnecting = 0
const wsReadyStateOpen = 1
const wsReadyStateClosing = 2 // eslint-disable-line
const wsReadyStateClosed = 3 // eslint-disable-line
const pingTimeout = 30000
const port = process.env.PORT || 4444
// @ts-ignore
const wss = new ws.Server({ noServer: true })
const server = http.createServer((request, response) => {
response.writeHead(200, { 'Content-Type': 'text/plain' })
response.end('okay')
})
/**
* Map froms topic-name to set of subscribed clients.
* @type {Map<string, Set<any>>}
*/
const topics = new Map()
/**
* @param {any} conn
* @param {object} message
*/
const send = (conn, message) => {
if (conn.readyState !== wsReadyStateConnecting && conn.readyState !== wsReadyStateOpen) {
conn.close()
}
try {
conn.send(JSON.stringify(message))
} catch (e) {
conn.close()
}
}
Can i get help how to deploy my project on aws. I read all the thread from this community but couldn’t find the related solution.
Thank you for helping in advance.