[GH-ISSUE #12] XHR Poll Error - connecting to a acebase server from the browser #10

Closed
opened 2026-05-23 08:33:59 -06:00 by gitea-mirror · 8 comments
Owner

Originally created by @theoparis on GitHub (Jul 15, 2021).
Original GitHub issue: https://github.com/appy-one/acebase-client/issues/12

Originally assigned to: @appy-one on GitHub.

Hi, so I'm hosting a acebase-server instance on my VPS. I was able to navigate to the acebase server's web manager panel, which seems to be working fine. However, when I used it in a react application in the browser it kept giving me XHR poll errors. There are no errors besides the repeated xhr error. I'd think it would be due to connection issues but I don't know how to solve it...

Here is the output in the inspector console on my browser:

[data] Connecting to AceBase server ****
[data] WARNING: The server you are connecting to does not use https, any data transferred may be intercepted!
[data] Websocket connection error: Error: xhr poll error

It also seems to be working fine in node.js in a CLI command that I created.

Here is the client connection code (excluding the ip address obviously)

import { AceBaseClient } from "acebase-client";

export const createClient = async () => {
    const dbName = import.meta.env.VITE_DB_NAME || "data";
    const dbHost = import.meta.env.VITE_DB_HOST || "localhost";
    const dbPort = import.meta.env.VITE_DB_PORT || "5858";

    if (!dbName || !dbHost || !dbPort) {
        throw new Error("DB_NAME, DB_HOST, DB_PORT is not defined!");
    }

    const client = new AceBaseClient({
        dbname: dbName.toString(),
        host: dbHost.toString(),
        port: parseInt(dbPort.toString()),
        https: import.meta.env.VITE_DB_HTTPS === "true"
    });

    await client.ready();
    return client;
};
Originally created by @theoparis on GitHub (Jul 15, 2021). Original GitHub issue: https://github.com/appy-one/acebase-client/issues/12 Originally assigned to: @appy-one on GitHub. Hi, so I'm hosting a acebase-server instance on my VPS. I was able to navigate to the acebase server's web manager panel, which seems to be working fine. However, when I used it in a react application **in the browser** it kept giving me XHR poll errors. There are no errors besides the repeated xhr error. I'd think it would be due to connection issues but I don't know how to solve it... Here is the output in the inspector console on my browser: ``` [data] Connecting to AceBase server **** [data] WARNING: The server you are connecting to does not use https, any data transferred may be intercepted! [data] Websocket connection error: Error: xhr poll error ``` It also seems to be working fine in node.js in a CLI command that I created. Here is the client connection code (excluding the ip address obviously) ```typescript import { AceBaseClient } from "acebase-client"; export const createClient = async () => { const dbName = import.meta.env.VITE_DB_NAME || "data"; const dbHost = import.meta.env.VITE_DB_HOST || "localhost"; const dbPort = import.meta.env.VITE_DB_PORT || "5858"; if (!dbName || !dbHost || !dbPort) { throw new Error("DB_NAME, DB_HOST, DB_PORT is not defined!"); } const client = new AceBaseClient({ dbname: dbName.toString(), host: dbHost.toString(), port: parseInt(dbPort.toString()), https: import.meta.env.VITE_DB_HTTPS === "true" }); await client.ready(); return client; }; ```
Author
Owner

@appy-one commented on GitHub (Jul 16, 2021):

Which version of acebase-client are you using?

<!-- gh-comment-id:881660032 --> @appy-one commented on GitHub (Jul 16, 2021): Which version of acebase-client are you using?
Author
Owner

@appy-one commented on GitHub (Jul 16, 2021):

My first attempt at debugging this would be checking if all environment variables are correct.
What if you'd console.log all those (including your https var), do they point to the right server?

<!-- gh-comment-id:881668268 --> @appy-one commented on GitHub (Jul 16, 2021): My first attempt at debugging this would be checking if all environment variables are correct. What if you'd `console.log` all those (including your https var), do they point to the right server?
Author
Owner

@appy-one commented on GitHub (Jul 22, 2021):

If this is still an issue, please reply. I will be closing it otherwise

<!-- gh-comment-id:884692437 --> @appy-one commented on GitHub (Jul 22, 2021): If this is still an issue, please reply. I will be closing it otherwise
Author
Owner

@paradis-A commented on GitHub (Sep 6, 2021):

I'm also having the same issue. Im using client version 1.5.1,

<!-- gh-comment-id:913339060 --> @paradis-A commented on GitHub (Sep 6, 2021): I'm also having the same issue. Im using client version 1.5.1,
Author
Owner

@appy-one commented on GitHub (Sep 8, 2021):

If XHR polls fail, the server is either not running at the same address you configured in the client, or unreachable because of a misconfigured firewall or proxy server in between. Try connecting to your server in the browser to test your settings. Example: if your server is running with https on myserver.com port 8735, simply go to https://myserver.com:8735/ in your browser. If that doesn't work, check your server, firewall and/or (reverse) proxy server configurations

<!-- gh-comment-id:915025412 --> @appy-one commented on GitHub (Sep 8, 2021): If XHR polls fail, the server is either not running at the same address you configured in the client, or unreachable because of a misconfigured firewall or proxy server in between. Try connecting to your server in the browser to test your settings. Example: if your server is running with https on myserver.com port 8735, simply go to https://myserver.com:8735/ in your browser. If that doesn't work, check your server, firewall and/or (reverse) proxy server configurations
Author
Owner

@paradis-A commented on GitHub (Sep 16, 2021):

client actually works on vanilla js. It's just bundling problem on my end.

<!-- gh-comment-id:920871249 --> @paradis-A commented on GitHub (Sep 16, 2021): client actually works on vanilla js. It's just bundling problem on my end.
Author
Owner

@paradis-A commented on GitHub (Nov 27, 2021):

if anyone in the future encountering this and using typescript. You can directly import the built browser js from dist folder
add this to your tsconfig.json

{
  "compilerOptions": {
      "paths": {
        "acebase-client/dist/browser": ["node_modules/acebase-client/index.d.ts"]
     }, 
}

so in your ts file

 import {AceBaseClient} from "acebase-client/dist/browser"
    const db = new AceBaseClient({
        host: "localhost",
        port: 5757,
        dbname: "mydb",
        https: false,
    });
    db.ready(() => {
        console.log("Connected successfully");
    });

this works for me

<!-- gh-comment-id:980637002 --> @paradis-A commented on GitHub (Nov 27, 2021): if anyone in the future encountering this and using typescript. You can directly import the built browser js from dist folder add this to your tsconfig.json ```json { "compilerOptions": { "paths": { "acebase-client/dist/browser": ["node_modules/acebase-client/index.d.ts"] }, } ``` so in your ts file ```typescript import {AceBaseClient} from "acebase-client/dist/browser" const db = new AceBaseClient({ host: "localhost", port: 5757, dbname: "mydb", https: false, }); db.ready(() => { console.log("Connected successfully"); }); ``` this works for me
Author
Owner

@appy-one commented on GitHub (May 16, 2022):

client actually works on vanilla js. It's just bundling problem on my end.

Which bundler do you use?

<!-- gh-comment-id:1127970142 --> @appy-one commented on GitHub (May 16, 2022): > client actually works on vanilla js. It's just bundling problem on my end. Which bundler do you use?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase-client#10
No description provided.