apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
63.13k stars 13.99k forks source link

Proxy is unable to function properly #29913

Open mkRui opened 3 months ago

mkRui commented 3 months ago

Bug description

The agent cannot function properly after restarting listen to 9000 the browser display Error occurred while trying to proxy: localhost:9000/ console [HPM] Error occurred while proxying request localhost:9000/favicon.ico to http://xxxxx:8000/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

I can start normally on other devices, I don't know if any settings are affecting it macos 13.6.7

How to reproduce the bug

This error was not found on other devices

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

dosubot[bot] commented 3 months ago

Hello, @mkRui! I'm here to help you with any bugs, questions, or contributions you have for the repository. Let me know how I can assist you!

The ECONNREFUSED error indicates that the connection attempt to localhost:9000 was actively refused, likely because there is no server listening on that port or another service is already using it. Additionally, the ERR_SERVER_ALREADY_LISTEN error suggests that the server.listen() method was called while a server was already active on that port.

To resolve this issue, follow these steps:

  1. Check for Running Instances: Ensure that no other instances of the server are running on port 9000. Use the following command to check if the port is in use:

    lsof -i :9000

    If a process is using the port, terminate it using the kill command with the process ID (PID) obtained from the previous step:

    kill -9 <PID>
  2. Change the Port: If terminating the process is not an option, you can change the port Superset uses. Modify the docker-compose.yaml file or the relevant configuration to use a different port:

    superset:
       ports:
         - 9001:9000  # Change the host port to 9001
  3. Restart Superset: Restart the Superset service to apply the changes:

    docker compose up
  4. Verify Configuration Files: Ensure that the configuration files (config.json, nginx.conf, docker-compose.yml) are correctly set up to match the port settings. Misconfigurations in these files can also lead to connection issues [1][2][3].

By following these steps, you should be able to resolve the port conflict and get the proxy functioning properly.

To continue talking to Dosu, mention @dosu.

mkRui commented 3 months ago

@dosu kill -9 <PID> No effect What I am using is superset-frontend npm ci npm run dev-server -- --env=--superset=http://xxxx:8000/

dosubot[bot] commented 3 months ago

To resolve the proxy issue with the Superset frontend, ensure that the backend server (Superset server) is running and accessible at the specified port. The error [ECONNREFUSED] indicates that the connection to the backend server was refused, which typically means that the server is not running or is not accessible at the specified address and port.

Here are the steps to resolve the issue:

  1. Ensure the Superset Backend is Running: Make sure that the Superset backend server is running on the specified port (e.g., http://xxxx:8000). You can start the backend server using the following command:

    superset run -p 8000 --with-threads --reload --debugger --debug
  2. Check the Configuration: Verify that the supersetPort and supersetUrl are correctly set to point to your running Superset backend server. In your case, it seems you are using a custom URL. Ensure that the URL is correct and the server is accessible.

  3. Modify the Configuration if Necessary: If your Superset backend is running on a different port or URL, update the configuration accordingly. For example, if your backend is running on port 8000, you can modify the configuration like this:

    const { supersetPort = 8000, superset: supersetUrl = 'http://xxxx:8000' } = parsedEnvArg();
    const backend = (supersetUrl || `http://localhost:${supersetPort}`).replace(
      '//+$/',
      '',
    ); // strip ending backslash
  4. Restart the Frontend Development Server: After making any changes, restart your frontend development server to apply the new configuration. You can start the Webpack dev server using the following command:

    npm run dev-server -- --env=--superset=http://xxxx:8000

Additionally, ensure that the webpack.config.js file is correctly set up to handle the proxy configuration. Here is the relevant part of the webpack.config.js file:

const getProxyConfig = require('./webpack.proxy-config');

let proxyConfig = getProxyConfig();

if (isDevMode) {
  config.devtool = 'eval-cheap-module-source-map';
  config.devServer = {
    onBeforeSetupMiddleware(devServer) {
      // load proxy config when manifest updates
      const { afterEmit } = getCompilerHooks(devServer.compiler);
      afterEmit.tap('ManifestPlugin', manifest => {
        proxyConfig = getProxyConfig(manifest);
      });
    },
    historyApiFallback: true,
    hot: true,
    port: devserverPort,
    // Only serves bundled files from webpack-dev-server
    // and proxy everything else to Superset backend
    proxy: [
      // functions are called for every request
      () => proxyConfig,
    ],
    client: {
      overlay: {
        errors: true,
        warnings: false,
        runtimeErrors: error => !/ResizeObserver/.test(error.message),
      },
      logging: 'error',
    },
    static: path.join(process.cwd(), '../static/assets'),
  };
}

By ensuring that the backend server is running and accessible at the specified address and port, and that the Webpack configurations are correctly set up, you should be able to resolve the proxy issue [1][2].

To continue talking to Dosu, mention @dosu.

mkRui commented 3 months ago

@dosu

const { supersetPort = 8000, superset: supersetUrl = 'http://xxxx:8000' } = parsedEnvArg();
const backend = (supersetUrl || `http://localhost:${supersetPort}`).replace(
  '//+$/',
  '',
); // strip ending backslash

No effect

[HPM] Error occurred while proxying request localhost:8000/favicon.ico to http://xxxxx:8000/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
dosubot[bot] commented 3 months ago

To resolve the ECONNREFUSED error, ensure the following:

  1. Backend Server is Running: Verify that the Superset backend server is running and accessible at http://xxxx:8000. You can start the backend server with:

    superset run -p 8000 --with-threads --reload --debugger --debug
  2. Check Network Connectivity: Ensure there are no network issues or firewalls blocking the connection between the frontend and backend.

  3. Verify Configuration: Double-check the configuration in your webpack.proxy-config.js to ensure it correctly points to the backend URL:

    const { supersetPort = 8000, superset: supersetUrl = 'http://xxxx:8000' } = parsedEnvArg();
    const backend = (supersetUrl || `http://localhost:${supersetPort}`).replace(
      '//+$/',
      '',
    ); // strip ending backslash
  4. Restart Frontend Server: After verifying the backend is running and the configuration is correct, restart the frontend development server:

    npm run dev-server -- --env=--superset=http://xxxx:8000

If the issue persists, check the logs for additional error messages that might provide more insight into the problem [1][2][3].

To continue talking to Dosu, mention @dosu.

mkRui commented 3 months ago

[HPM] Proxy created: /  -> http://129.226.215.20:8088
(node:10416) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
(Use `node --trace-deprecation ...` to show where the warning was created)
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8088/
<i> [webpack-dev-server] On Your Network (IPv4): http://192.168.31.149:8088/
<i> [webpack-dev-server] On Your Network (IPv6): http://[fe80::1]:8088/
<i> [webpack-dev-server] Content not from webpack is served from '/Users/mkrui/Downloads/BlogWeb/superset/static/assets' directory
<i> [webpack-dev-server] 404s will fallback to '/index.html'
1083 assets
12338 modules
webpack 5.93.0 compiled successfully in 86616 ms
[HPM] Proxy created: /  -> http://129.226.215.20:8088
[HPM] Error occurred while proxying request localhost:8088/ to http://129.226.215.20:8088/ [ECONNRESET] (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while proxying request localhost:8088/favicon.ico to http://129.226.215.20:8088/ [ECONNRESET] (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while proxying request 192.168.31.149:8088/ to http://129.226.215.20:8088/ [ECONNRESET] (https://nodejs.org/api/errors.html#errors_common_system_errors)
[HPM] Error occurred while proxying request 192.168.31.149:8088/favicon.ico to http://129.226.215.20:8088/ [ECONNRESET] (https://nodejs.org/api/errors.html#errors_common_system_errors)

@dosu. No effect

StarHosea commented 3 months ago

same here

dosubot[bot] commented 3 months ago

To resolve the ECONNRESET errors when proxying requests, ensure the following:

  1. Backend Server Accessibility: Verify that the backend server at http://129.226.215.20:8088 is running and accessible. You can check this by directly accessing the URL in your browser or using a tool like curl:

    curl http://129.226.215.20:8088
  2. Network Issues: Ensure there are no network issues or firewalls blocking the connection between your frontend and the backend server.

  3. Proxy Configuration: Double-check your proxy configuration in webpack.proxy-config.js to ensure it correctly points to the backend URL:

    const { supersetPort = 8088, superset: supersetUrl = 'http://129.226.215.20:8088' } = parsedEnvArg();
    const backend = (supersetUrl || `http://localhost:${supersetPort}`).replace(
      '//+$/',
      '',
    ); // strip ending backslash
  4. Restart Frontend Server: After verifying the backend is running and the configuration is correct, restart the frontend development server:

    npm run dev-server -- --env=--superset=http://129.226.215.20:8088
  5. Enable Detailed Logging: Enable detailed logging for the proxy middleware to get more insights into the connection issues. Modify the webpack.config.js to include detailed logging:

    config.devServer = {
      // other configurations
      client: {
        logging: 'debug', // Change this to 'debug' for more detailed logs
      },
    };
  6. Check Logs: Check the logs for additional error messages that might provide more insight into the problem.

By following these steps, you should be able to resolve the ECONNRESET errors and get the proxy functioning properly [1][2][3].

To continue talking to Dosu, mention @dosu.

CoderSxy commented 2 months ago

same here

TacoBel42 commented 1 month ago

same, any updates?

rusackas commented 1 month ago

No updates AFAIK. I suspect since the original report is trying to proxy port 8000 (instead of the usual 8088) they probably fiddled with the config, but didn't adjust it everywhere. I run this way on master all the time, and the current codebase seems to be fine. I think we need more info (version/sha, OS, etc) if we're going to effectively troubleshoot this.

TacoBel42 commented 1 month ago

@rusackas tried with node 18:

1. with default 8088 
2. npm run dev-server -- --env=--supersetPort=8088
3. npm run dev-server -- --env=--superset=localhost:8088/
4. npm run dev-server -- --env=--superset=http://localhost:8088/
5. npm run dev-server -- --env=--superset=http://localhost:8088

always getting[HPM] Error occurred while proxying request localhost:9000/ to http://localhost:8088/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

tried with node 20: no ECONNREFUSED, but getting text on /login page

(�/�`�2zz��.�h�z0WБ���&�|w�P٤��} }��ZyS��B�J��,� YT ����w4��e<��;��;���>��}�ȓ;�7�������rx�����ٳ��_�9�>�g�7�#A�xlx�x�۱�4��Du�Mǝ�P�
TacoBel42 commented 1 month ago

@rusackas we forked 4.0.1 (rc2). Does 4.0.1 rc3 have any fixes?

harrychristianx commented 4 weeks ago

npm run dev-server -- --env=--superset=http://xxxx:8000/

experiencing this issue too on rc3 and rc4

(�/�`�2�zz���.�h�z0WБ���&�|w�P�٤��} }��ZyS����B�J���,� YT �������w�4���e<����;��;������>����}�ȓ;�7�������rx�����ٳ��_�9�>��g�7�#A�xlx�x�۱�4��Du��Mǝ�P�

Physicalpixel commented 6 days ago

Hi there! I am facing this issue on 4.0.2, has anyone solved this? Could you please share the what steps helped?