I'm using socket.io with easyrtc to have a p2p video chat. Working example at https://github.com/merictaze/enlargify with following package versions
"express": "^4.15.2",
"easyrtc": "1.0.x", // [email protected]
"socket.io": "^1.4.5"
The easyrtc logic used is at https://github.com/merictaze/enlargify/blob/master/public/resources/js/app.js
However, if i bump up easyrtc version to 1.1 The code stops working. I've even tried the beta branch.
"express": "^4.15.2",
"easyrtc": "priologic/easyrtc#beta",
"socket.io": "^1.4.5"
I know this isn't helping much, so on further investigation i found out that it fails at this call
easyrtc.call(self.partnerId, successCB, failureCB, acceptedCB);
The Error code from failureCB is
MSG_REJECT_TARGET_EASYRTCID
On the server side the log shows
2017-12-07T07:02:40.477Z - debug - EasyRTC: [enlargify_app][fNhseVCWzi8XXhn5] EasyRTC command received with msgType [offer] undefined
2017-12-07T07:02:40.478Z - warning - EasyRTC: Attempt to request non-existent connection key: '0xv7UpIAlVeAzEedAAAA' undefined
2017-12-07T07:02:40.479Z - warning - EasyRTC: [enlargify_app][fNhseVCWzi8XXhn5] Could not send WebRTC signal to client [0xv7UpIAlVeAzEedAAAA]. They may no longer be online. undefined
However, reverting the easyrtc version back in package.json works as it does on the demo here http://enlargify.herokuapp.com/
I want to update the easyrtc version because of the safari support in the beta branch. I found the demos working smoothly.
ps. I did update the socket.io version and updated the deprecated calls e.g
partnerSocket = io.sockets.socket(socket.partnerId);
partnerSocket.emit("disconnect_partner", socket.id);
to
io.to(socket.partnerId).emit("disconnect_partner", socket.id);
Further investigations show that the socket.id generated on the client side is different from the one on server. That's why the two peers are unable to connect.
Any idea how i can get success function of easyrtc.connect to return the correct socketID?
Answering my own question here so if someone else stumbles upon this, they won't waste hours like i did.
The reason for the difference in Ids on client and server is because prior to version of [email protected], easyrtc relied on SocketIO's ID and used it as the EASYRTCID as well. This meant that both socket.id and easyrtcid can be referenced interchangeably. That's why it worked in old versions.
As explained at https://github.com/priologic/easyrtc/issues/185 they changed the functionality and made EASYRTCID based on a new pattern. As signaling server (socketIO) would emit to socket.id while easyrtc when initiating the calls would use easyrtcid. Hence business logic is needed to pass easyrtcids between peers via socket in order to make easryrtc call.
In addition to above we also need to tell the easyrtc object to use the socket instance of the signaling server. I followed this example https://demo.easyrtc.com/demos/demo_instant_messaging_selfconnect.html