metaplex-foundation/amman

WS fails to connect

saberistic opened this issue · 4 comments

I am trying to run amman and get following and it keeps printing last line

$ amman start
Loading config from /home/saber/code/baxus-anchor/.ammanrc.js
Running validator with 1 custom program(s) and 0 remote account(s) preloaded
Launching new solana-test-validator with programs predeployed and ledger at ./test-ledger
Successfully launched Relay at :::50474
ws error: connect ECONNREFUSED 127.0.0.1:8900
Successfully launched MockStorageServer at :::50475
ws error: connect ECONNREFUSED 127.0.0.1:8900
ws error: connect ECONNREFUSED 127.0.0.1:8900

Config:

module.exports = {
  validator: {
    killRunningValidators: true,
    programs: [
      { 
        label: 'Token Metadata Program',
        programId: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
        deployPath: '../metaplex-program-library/token-metadata/'
      },
    ],
    jsonRpcUrl: 'localhost',
    websocketUrl: 'localhost',
    commitment: 'confirmed',
    ledgerDir: './test-ledger',
    resetLedger: true,
    verifyFees: false,
    detached: process.env.CI != null,
  },
  relay: {
    enabled: process.env.CI == null,
    killlRunningRelay: true,
  },
  storage: {
    enabled: process.env.CI == null,
    storageId: 'mock-storage',
    clearOnStart: true,
  },
}

Attempting to run amman with imports from @metaplex-foundation/amman gives following error

saber@pop-os:~/code/amman$ amman start
Having trouble loading amman config from undefined
/home/saber/code/amman/.ammanrc.js:1
import { LOCALHOST, tmpLedgerDir } from '@metaplex-foundation/amman'
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1049:15)
    at Module._compile (node:internal/modules/cjs/loader:1084:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
    at Module.load (node:internal/modules/cjs/loader:998:32)
    at Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1022:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at tryLoadLocalConfigRc (/home/linuxbrew/.linuxbrew/lib/node_modules/@metaplex-foundation/amman/dist/cli/commands/start.js:64:24)
    at async resolveConfig (/home/linuxbrew/.linuxbrew/lib/node_modules/@metaplex-foundation/amman/dist/cli/commands/start.js:50:53)
Rerun `amman --help` for more information

@amirsaber Did you ever resolve the ECONNREFUSED websocket error on port 8900? I'm still running into this error today.

I couldn't figure the exact root cause but it was a configuration issue on my side. I used this repo https://github.com/metaplex-foundation/js with default config file, ran yarn && yarn build && yarn amman:start. It worked with loaded metaplex programs

It looks like the WebSocket connection is failing to connect to localhost:8900. This could be due to a few reasons:

  1. The WebSocket server is not running on localhost:8900.
  2. There is a firewall blocking the connection to localhost:8900.
  3. The WebSocket server is not configured to accept connections from localhost.

You can try the following steps to troubleshoot the issue:

  1. Check if the WebSocket server is running on localhost:8900. If it is not, you may need to start it or update the configuration to use the correct WebSocket URL.
  2. Check if there is a firewall blocking the connection to localhost:8900. You may need to add an exception to the firewall to allow the connection.
  3. Check if the WebSocket server is configured to accept connections from localhost. If it is not, you may need to update the configuration to allow connections from localhost.

Once you have identified and resolved the issue, you should be able to connect to the WebSocket server and run amman successfully.