Question:
wixRealtime.Subscribe() works on Preview mode within the Studio Editor, but does not work on the live site - even when logged-in as the exact same user. Why does Subscribe() break on my live site?
Product:
Editor X
What are you trying to achieve:
To simplify the problem, I have copied JUST the subscribe() logic to a new test page. I am trying to get it so that:
- On Page Load → run testFunction
- testFunction should subscribe to a simple fake channel
- The user should subscribe successfully. This currently errors on live.
*Error Message: {ErrorCode: 2, Message: ‘subscribe failed’}
What have you already tried:
I have ripped out just the subscribe logic on a blank page to keep it simple. I have also tried various logic-approaches, async+await, then/catch, etc. No luck.
Additional information:
import wixRealtimeFrontend from 'wix-realtime-frontend';
$w.onReady(function () {
testSubscribe();
});
export function testSubscribe() {
console.log("attempting to dial into a channel");
const channel = {"name": "someChannel"};
wixRealtimeFrontend.subscribe(channel, (message, channel) => {
let payload = message.payload;
if(message.publisher) {
let publisherId = message.publisher.id;
console.log("message receieved from channel");
}
})
.then((id) => {
console.log("subscription successful");
});
}
Here is a picture: