Cannot connect to Baqend WebSocket server

I’m trying to connect to Baqend’s wss:// server to use their realtime queries feature. I can do so using a web-browser but Fuse doesn’t seem to make it happen.

I try to debug the WebSockets polyfill. It seems that the function handleEvent(obj, type, data) { in WebSocketApi.js is not receiving any ‘open’ or ‘receive’ event. When I console.log(type); it only prints out “close” to the log window.

How do I fix this. Please help.

PS. I’m using Fuse v1.0.0

Hi karimzai,

is there a complete, minimal reproduction that you could share for us to take a look at?

Well I’m using a third-party service (Baqend), that has their own javascript SDK. The SDK handles the communication with the wss:// server. The SDK works in the browser but not in Fuse.

Anyway following code can be used to reproduce the unintended behaviour:

var db = require("baqend-realtime.js").db;

function btnOnClick(){
    db.connect("<your_baqend_app_name>",true); //true is to connect to wss:// instead of ws:// - both doesn't work.
    db.login("username","password").then(function(){
        var query = db.Customers.find();
        query.resultStream(function(items){ // this is where the websocket connection is established.
            console.log(items); // never logs anything
        });
    });
}

Which targets have you tested this on? Is the problem isolated to one - Local, Android, iOS; or is it across all of them?

I don’t have an Android device. But the issue persists both on Local and iOS previews.

Have you tested if ws:// works (as opposed to wss://)? Are you using a custom port on the target?

And finally, would you be able to provide a ready-to-run example that we could give a go?

Yes I did test both ws:// and wss:// they both don’t work. There shouldn’t be any custom port on the target because it’s a standard service used by many people, besides as I said earlier the same javascript file successfully connects to the server when used in a web browser but won’t work from fusetools.

Following code is all you need to make a ready-to-run example:

var db = require("baqend-realtime.js").db;

function btnOnClick(){
    db.connect("<your_baqend_app_name>",true); //true is to connect to wss:// instead of ws:// - both doesn't work.
    db.ready(function(){
        db.login("username","password").then(function(){
            var query = db.Customers.find(); // Customers is a table in the baqend database. you can use any.
            query.resultStream(function(items){ // this is where the websocket connection is established.
                console.log(items); // never logs anything
            });
        });
    });
}

Thanks

Hello everyone,

Any update on this, as I am facing the same problem.

Thanks

Hi,
I just want to provide a simpler case to reproduce and test the error. We provide real-time in our app-starter app, therefore you can simply test the web socket issue by using the WebSocket endpoint of that app.

Simple Code to reproduce the error:

var ws = new WebSocket('wss://app-starter.events.baqend.com/v1/events'); // also ws:// can be used
ws.onopen = function() { console.log('opened') };
ws.onclose = function() { console.log('closed') };
//expect opened to be logged but closed is called immediately

Hope that helps solve the issue, you can also PM me if we can provide help or there is any issue on our side.

Sorry for not replying sooner, but this is a confirmed bug and we are working on it.

Any updates on this?