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.
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
});
});
}
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
});
});
});
}
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.